From 55cd3a951fdb19233045f78d8e5f0c43803da9d7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:32:18 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#489) - [ ] 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 --- java-os-config/google-cloud-os-config/pom.xml | 16 + .../osconfig/v1/OsConfigServiceClient.java | 15 + .../osconfig/v1/OsConfigServiceSettings.java | 23 +- .../v1/OsConfigZonalServiceClient.java | 38 +- .../v1/OsConfigZonalServiceSettings.java | 23 +- ...ttpJsonOsConfigServiceCallableFactory.java | 105 ++ .../v1/stub/HttpJsonOsConfigServiceStub.java | 930 ++++++++++ ...onOsConfigZonalServiceCallableFactory.java | 105 ++ .../HttpJsonOsConfigZonalServiceStub.java | 1004 +++++++++++ .../v1/stub/OsConfigServiceStubSettings.java | 53 +- .../v1/stub/OsConfigZonalServiceStub.java | 6 +- .../OsConfigZonalServiceStubSettings.java | 53 +- .../v1alpha/OsConfigZonalServiceClient.java | 38 +- .../v1alpha/OsConfigZonalServiceSettings.java | 23 +- ...onOsConfigZonalServiceCallableFactory.java | 105 ++ .../HttpJsonOsConfigZonalServiceStub.java | 1150 ++++++++++++ .../stub/OsConfigZonalServiceStub.java | 6 +- .../OsConfigZonalServiceStubSettings.java | 53 +- .../v1beta/OsConfigServiceClient.java | 15 + .../v1beta/OsConfigServiceSettings.java | 23 +- ...ttpJsonOsConfigServiceCallableFactory.java | 105 ++ .../stub/HttpJsonOsConfigServiceStub.java | 1311 ++++++++++++++ .../stub/OsConfigServiceStubSettings.java | 53 +- .../v1/OsConfigServiceClientHttpJsonTest.java | 1242 +++++++++++++ ...sConfigZonalServiceClientHttpJsonTest.java | 1359 ++++++++++++++ ...sConfigZonalServiceClientHttpJsonTest.java | 1576 +++++++++++++++++ .../OsConfigServiceClientHttpJsonTest.java | 1447 +++++++++++++++ .../cancelpatchjob/AsyncCancelPatchJob.java | 46 + .../cancelpatchjob/SyncCancelPatchJob.java | 42 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreatePatchDeployment.java | 48 + .../SyncCreatePatchDeployment.java | 45 + ...PatchdeploymentspatchdeploymentString.java | 46 + ...PatchdeploymentspatchdeploymentString.java | 46 + .../AsyncDeletePatchDeployment.java | 47 + .../SyncDeletePatchDeployment.java | 42 + ...etePatchDeploymentPatchdeploymentname.java | 39 + .../SyncDeletePatchDeploymentString.java | 38 + .../executepatchjob/AsyncExecutePatchJob.java | 54 + .../executepatchjob/SyncExecutePatchJob.java | 50 + .../AsyncGetPatchDeployment.java | 46 + .../SyncGetPatchDeployment.java | 42 + ...GetPatchDeploymentPatchdeploymentname.java | 39 + .../SyncGetPatchDeploymentString.java | 39 + .../getpatchjob/AsyncGetPatchJob.java | 46 + .../getpatchjob/SyncGetPatchJob.java | 42 + .../SyncGetPatchJobPatchjobname.java | 39 + .../getpatchjob/SyncGetPatchJobString.java | 39 + .../AsyncListPatchDeployments.java | 50 + .../AsyncListPatchDeploymentsPaged.java | 57 + .../SyncListPatchDeployments.java | 47 + .../SyncListPatchDeploymentsProjectname.java | 42 + .../SyncListPatchDeploymentsString.java | 42 + .../AsyncListPatchJobInstanceDetails.java | 51 + ...AsyncListPatchJobInstanceDetailsPaged.java | 59 + .../SyncListPatchJobInstanceDetails.java | 48 + ...stPatchJobInstanceDetailsPatchjobname.java | 42 + ...SyncListPatchJobInstanceDetailsString.java | 42 + .../listpatchjobs/AsyncListPatchJobs.java | 51 + .../AsyncListPatchJobsPaged.java | 58 + .../listpatchjobs/SyncListPatchJobs.java | 47 + .../SyncListPatchJobsProjectname.java | 41 + .../SyncListPatchJobsString.java | 41 + .../AsyncPausePatchDeployment.java | 46 + .../SyncPausePatchDeployment.java | 43 + ...usePatchDeploymentPatchdeploymentname.java | 39 + .../SyncPausePatchDeploymentString.java | 39 + .../AsyncResumePatchDeployment.java | 46 + .../SyncResumePatchDeployment.java | 43 + ...umePatchDeploymentPatchdeploymentname.java | 40 + .../SyncResumePatchDeploymentString.java | 39 + .../AsyncUpdatePatchDeployment.java | 47 + .../SyncUpdatePatchDeployment.java | 44 + ...chdeploymentspatchdeploymentFieldmask.java | 45 + .../executepatchjob/SyncExecutePatchJob.java | 46 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateOSPolicyAssignment.java | 51 + .../AsyncCreateOSPolicyAssignmentLRO.java | 53 + .../SyncCreateOSPolicyAssignment.java | 47 + ...tLocationnameOspolicyassignmentString.java | 48 + ...ignmentStringOspolicyassignmentString.java | 47 + .../AsyncDeleteOSPolicyAssignment.java | 50 + .../AsyncDeleteOSPolicyAssignmentLRO.java | 53 + .../SyncDeleteOSPolicyAssignment.java | 45 + ...olicyAssignmentOspolicyassignmentname.java | 42 + .../SyncDeleteOSPolicyAssignmentString.java | 40 + .../getinventory/AsyncGetInventory.java | 50 + .../getinventory/SyncGetInventory.java | 46 + .../SyncGetInventoryInventoryname.java | 40 + .../getinventory/SyncGetInventoryString.java | 40 + .../AsyncGetOSPolicyAssignment.java | 50 + .../SyncGetOSPolicyAssignment.java | 46 + ...olicyAssignmentOspolicyassignmentname.java | 43 + .../SyncGetOSPolicyAssignmentString.java | 41 + .../AsyncGetOSPolicyAssignmentReport.java | 51 + .../SyncGetOSPolicyAssignmentReport.java | 48 + ...entReportOspolicyassignmentreportname.java | 45 + ...SyncGetOSPolicyAssignmentReportString.java | 43 + .../AsyncGetVulnerabilityReport.java | 49 + .../SyncGetVulnerabilityReport.java | 45 + .../SyncGetVulnerabilityReportString.java | 40 + ...rabilityReportVulnerabilityreportname.java | 43 + .../listinventories/AsyncListInventories.java | 58 + .../AsyncListInventoriesPaged.java | 66 + .../listinventories/SyncListInventories.java | 54 + .../SyncListInventoriesInstancename.java | 43 + .../SyncListInventoriesString.java | 43 + .../AsyncListOSPolicyAssignmentReports.java | 58 + ...yncListOSPolicyAssignmentReportsPaged.java | 65 + .../SyncListOSPolicyAssignmentReports.java | 53 + ...ReportsInstanceospolicyassignmentname.java | 48 + ...ncListOSPolicyAssignmentReportsString.java | 46 + .../AsyncListOSPolicyAssignmentRevisions.java | 56 + ...cListOSPolicyAssignmentRevisionsPaged.java | 64 + .../SyncListOSPolicyAssignmentRevisions.java | 51 + ...gnmentRevisionsOspolicyassignmentname.java | 46 + ...ListOSPolicyAssignmentRevisionsString.java | 46 + .../AsyncListOSPolicyAssignments.java | 52 + .../AsyncListOSPolicyAssignmentsPaged.java | 60 + .../SyncListOSPolicyAssignments.java | 49 + ...ncListOSPolicyAssignmentsLocationname.java | 44 + .../SyncListOSPolicyAssignmentsString.java | 43 + .../AsyncListVulnerabilityReports.java | 56 + .../AsyncListVulnerabilityReportsPaged.java | 64 + .../SyncListVulnerabilityReports.java | 53 + ...cListVulnerabilityReportsInstancename.java | 45 + .../SyncListVulnerabilityReportsString.java | 44 + .../AsyncUpdateOSPolicyAssignment.java | 50 + .../AsyncUpdateOSPolicyAssignmentLRO.java | 52 + .../SyncUpdateOSPolicyAssignment.java | 46 + ...AssignmentOspolicyassignmentFieldmask.java | 46 + .../SyncGetOSPolicyAssignment.java | 47 + .../executepatchjob/SyncExecutePatchJob.java | 46 + .../SyncGetOSPolicyAssignment.java | 47 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateOSPolicyAssignment.java | 51 + .../AsyncCreateOSPolicyAssignmentLRO.java | 53 + .../SyncCreateOSPolicyAssignment.java | 47 + ...tLocationnameOspolicyassignmentString.java | 48 + ...ignmentStringOspolicyassignmentString.java | 47 + .../AsyncDeleteOSPolicyAssignment.java | 50 + .../AsyncDeleteOSPolicyAssignmentLRO.java | 53 + .../SyncDeleteOSPolicyAssignment.java | 45 + ...olicyAssignmentOspolicyassignmentname.java | 42 + .../SyncDeleteOSPolicyAssignmentString.java | 41 + .../AsyncGetInstanceOSPoliciesCompliance.java | 51 + .../SyncGetInstanceOSPoliciesCompliance.java | 48 + ...ianceInstanceospoliciescompliancename.java | 45 + ...GetInstanceOSPoliciesComplianceString.java | 44 + .../getinventory/AsyncGetInventory.java | 50 + .../getinventory/SyncGetInventory.java | 46 + .../SyncGetInventoryInventoryname.java | 40 + .../getinventory/SyncGetInventoryString.java | 40 + .../AsyncGetOSPolicyAssignment.java | 50 + .../SyncGetOSPolicyAssignment.java | 46 + ...olicyAssignmentOspolicyassignmentname.java | 43 + .../SyncGetOSPolicyAssignmentString.java | 41 + .../AsyncGetOSPolicyAssignmentReport.java | 51 + .../SyncGetOSPolicyAssignmentReport.java | 48 + ...entReportOspolicyassignmentreportname.java | 45 + ...SyncGetOSPolicyAssignmentReportString.java | 45 + .../AsyncGetVulnerabilityReport.java | 49 + .../SyncGetVulnerabilityReport.java | 45 + .../SyncGetVulnerabilityReportString.java | 40 + ...rabilityReportVulnerabilityreportname.java | 43 + ...syncListInstanceOSPoliciesCompliances.java | 57 + ...istInstanceOSPoliciesCompliancesPaged.java | 64 + ...SyncListInstanceOSPoliciesCompliances.java | 52 + ...anceOSPoliciesCompliancesLocationname.java | 45 + ...stInstanceOSPoliciesCompliancesString.java | 45 + .../listinventories/AsyncListInventories.java | 55 + .../AsyncListInventoriesPaged.java | 63 + .../listinventories/SyncListInventories.java | 51 + .../SyncListInventoriesInstancename.java | 42 + .../SyncListInventoriesString.java | 42 + .../AsyncListOSPolicyAssignmentReports.java | 58 + ...yncListOSPolicyAssignmentReportsPaged.java | 66 + .../SyncListOSPolicyAssignmentReports.java | 53 + ...ReportsInstanceospolicyassignmentname.java | 48 + ...ncListOSPolicyAssignmentReportsString.java | 47 + .../AsyncListOSPolicyAssignmentRevisions.java | 57 + ...cListOSPolicyAssignmentRevisionsPaged.java | 64 + .../SyncListOSPolicyAssignmentRevisions.java | 52 + ...gnmentRevisionsOspolicyassignmentname.java | 46 + ...ListOSPolicyAssignmentRevisionsString.java | 46 + .../AsyncListOSPolicyAssignments.java | 52 + .../AsyncListOSPolicyAssignmentsPaged.java | 60 + .../SyncListOSPolicyAssignments.java | 49 + ...ncListOSPolicyAssignmentsLocationname.java | 45 + .../SyncListOSPolicyAssignmentsString.java | 43 + .../AsyncListVulnerabilityReports.java | 53 + .../AsyncListVulnerabilityReportsPaged.java | 62 + .../SyncListVulnerabilityReports.java | 50 + ...cListVulnerabilityReportsInstancename.java | 45 + .../SyncListVulnerabilityReportsString.java | 44 + .../AsyncUpdateOSPolicyAssignment.java | 50 + .../AsyncUpdateOSPolicyAssignmentLRO.java | 52 + .../SyncUpdateOSPolicyAssignment.java | 46 + ...AssignmentOspolicyassignmentFieldmask.java | 46 + .../SyncGetOSPolicyAssignment.java | 47 + .../SyncGetOSPolicyAssignment.java | 47 + .../cancelpatchjob/AsyncCancelPatchJob.java | 43 + .../cancelpatchjob/SyncCancelPatchJob.java | 39 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../AsyncCreateGuestPolicy.java | 48 + .../SyncCreateGuestPolicy.java | 44 + ...cyProjectnameGuestpoliciesguestpolicy.java | 43 + ...tPolicyStringGuestpoliciesguestpolicy.java | 43 + .../AsyncCreatePatchDeployment.java | 47 + .../SyncCreatePatchDeployment.java | 44 + .../AsyncDeleteGuestPolicy.java | 47 + .../SyncDeleteGuestPolicy.java | 42 + .../SyncDeleteGuestPolicyGuestpolicyname.java | 38 + .../SyncDeleteGuestPolicyString.java | 38 + .../AsyncDeletePatchDeployment.java | 44 + .../SyncDeletePatchDeployment.java | 39 + .../executepatchjob/AsyncExecutePatchJob.java | 53 + .../executepatchjob/SyncExecutePatchJob.java | 49 + .../getguestpolicy/AsyncGetGuestPolicy.java | 46 + .../getguestpolicy/SyncGetGuestPolicy.java | 42 + .../SyncGetGuestPolicyGuestpolicyname.java | 39 + .../SyncGetGuestPolicyString.java | 39 + .../AsyncGetPatchDeployment.java | 43 + .../SyncGetPatchDeployment.java | 39 + .../getpatchjob/AsyncGetPatchJob.java | 43 + .../getpatchjob/SyncGetPatchJob.java | 39 + .../AsyncListGuestPolicies.java | 50 + .../AsyncListGuestPoliciesPaged.java | 57 + .../SyncListGuestPolicies.java | 47 + .../SyncListGuestPoliciesProjectname.java | 42 + .../SyncListGuestPoliciesString.java | 42 + .../AsyncListPatchDeployments.java | 49 + .../AsyncListPatchDeploymentsPaged.java | 56 + .../SyncListPatchDeployments.java | 46 + .../AsyncListPatchJobInstanceDetails.java | 50 + ...AsyncListPatchJobInstanceDetailsPaged.java | 58 + .../SyncListPatchJobInstanceDetails.java | 47 + ...SyncListPatchJobInstanceDetailsString.java | 41 + .../listpatchjobs/AsyncListPatchJobs.java | 50 + .../AsyncListPatchJobsPaged.java | 57 + .../listpatchjobs/SyncListPatchJobs.java | 46 + .../AsyncLookupEffectiveGuestPolicy.java | 48 + .../SyncLookupEffectiveGuestPolicy.java | 45 + .../AsyncPausePatchDeployment.java | 46 + .../SyncPausePatchDeployment.java | 43 + ...usePatchDeploymentPatchdeploymentname.java | 41 + .../SyncPausePatchDeploymentString.java | 39 + .../AsyncResumePatchDeployment.java | 46 + .../SyncResumePatchDeployment.java | 43 + ...umePatchDeploymentPatchdeploymentname.java | 41 + .../SyncResumePatchDeploymentString.java | 39 + .../AsyncUpdateGuestPolicy.java | 47 + .../SyncUpdateGuestPolicy.java | 43 + ...licyGuestpoliciesguestpolicyFieldmask.java | 43 + .../AsyncUpdatePatchDeployment.java | 47 + .../SyncUpdatePatchDeployment.java | 44 + ...chdeploymentspatchdeploymentFieldmask.java | 45 + .../executepatchjob/SyncExecutePatchJob.java | 46 + .../executepatchjob/SyncExecutePatchJob.java | 46 + 267 files changed, 22072 insertions(+), 32 deletions(-) create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.java create mode 100644 java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java create mode 100644 java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java create mode 100644 java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java create mode 100644 java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java create mode 100644 java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java create mode 100644 java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java diff --git a/java-os-config/google-cloud-os-config/pom.xml b/java-os-config/google-cloud-os-config/pom.xml index 06a53b8c9cbb..743227abdb68 100644 --- a/java-os-config/google-cloud-os-config/pom.xml +++ b/java-os-config/google-cloud-os-config/pom.xml @@ -66,6 +66,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -93,12 +97,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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java index 107dc0c9d8e8..3312e93ee6c1 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java @@ -114,6 +114,21 @@ * OsConfigServiceClient.create(osConfigServiceSettings); * } * + *

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.
+ * OsConfigServiceSettings osConfigServiceSettings =
+ *     OsConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigServiceClient osConfigServiceClient =
+ *     OsConfigServiceClient.create(osConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java index e61e21433dea..d984e7eb27a6 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java @@ -25,6 +25,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; @@ -184,11 +185,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigServiceStubSettings.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 OsConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -198,11 +206,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigServiceStubSettings.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); @@ -240,6 +254,11 @@ private static Builder createDefault() { return new Builder(OsConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java index dbcb9aef889e..779813c44aa0 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.osconfig.v1.stub.OsConfigZonalServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -110,13 +110,29 @@ * OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); * } * + *

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.
+ * OsConfigZonalServiceSettings osConfigZonalServiceSettings =
+ *     OsConfigZonalServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigZonalServiceClient osConfigZonalServiceClient =
+ *     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class OsConfigZonalServiceClient implements BackgroundResource { private final OsConfigZonalServiceSettings settings; private final OsConfigZonalServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of OsConfigZonalServiceClient with default settings. */ public static final OsConfigZonalServiceClient create() throws IOException { @@ -148,13 +164,17 @@ public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub s protected OsConfigZonalServiceClient(OsConfigZonalServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((OsConfigZonalServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected OsConfigZonalServiceClient(OsConfigZonalServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final OsConfigZonalServiceSettings getSettings() { @@ -169,10 +189,18 @@ public OsConfigZonalServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create an OS policy assignment. diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java index a9f891867d58..31ebc4ccbbf5 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java @@ -27,6 +27,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; @@ -219,11 +220,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigZonalServiceStubSettings.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 OsConfigZonalServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigZonalServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigZonalServiceStubSettings.defaultTransportChannelProvider(); } @@ -233,11 +241,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigZonalServiceStubSettings.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); @@ -276,6 +290,11 @@ private static Builder createDefault() { return new Builder(OsConfigZonalServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigZonalServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigZonalServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigZonalServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.java new file mode 100644 index 000000000000..878cde9b4224 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.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.osconfig.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 OsConfigService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigServiceCallableFactory + 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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java new file mode 100644 index 000000000000..29c595e68678 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java @@ -0,0 +1,930 @@ +/* + * 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.osconfig.v1.stub; + +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.PatchJobs; +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 OsConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigServiceStub extends OsConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + executePatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ExecutePatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchJobs:execute", + 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("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/GetPatchJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/patchJobs/*}", + 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(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/CancelPatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/patchJobs/*}:cancel", + 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(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobsRequest, PatchJobs.ListPatchJobsResponse> + listPatchJobsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ListPatchJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchJobs", + 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(PatchJobs.ListPatchJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigService/ListPatchJobInstanceDetails") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{parent=projects/*/patchJobs/*}/instanceDetails", + 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( + PatchJobs.ListPatchJobInstanceDetailsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/CreatePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchDeployments", + 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, "patchDeploymentId", request.getPatchDeploymentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/GetPatchDeployment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ListPatchDeployments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchDeployments", + 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( + PatchDeployments.ListPatchDeploymentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deletePatchDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/DeletePatchDeployment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}", + 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< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/UpdatePatchDeployment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{patchDeployment.name=projects/*/patchDeployments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "patchDeployment.name", + request.getPatchDeployment().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("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/PausePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}:pause", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ResumePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}:resume", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + executePatchJobCallable; + private final UnaryCallable getPatchJobCallable; + private final UnaryCallable + cancelPatchJobCallable; + private final UnaryCallable + listPatchJobsCallable; + private final UnaryCallable + listPatchJobsPagedCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable; + private final UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable; + private final UnaryCallable + deletePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigServiceStub create(OsConfigServiceStubSettings settings) + throws IOException { + return new HttpJsonOsConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + executePatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(executePatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + cancelPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listPatchJobsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listPatchJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchJobInstanceDetailsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(createPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(getPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchDeploymentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deletePatchDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(updatePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(pausePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(resumePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.executePatchJobCallable = + callableFactory.createUnaryCallable( + executePatchJobTransportSettings, settings.executePatchJobSettings(), clientContext); + this.getPatchJobCallable = + callableFactory.createUnaryCallable( + getPatchJobTransportSettings, settings.getPatchJobSettings(), clientContext); + this.cancelPatchJobCallable = + callableFactory.createUnaryCallable( + cancelPatchJobTransportSettings, settings.cancelPatchJobSettings(), clientContext); + this.listPatchJobsCallable = + callableFactory.createUnaryCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobInstanceDetailsCallable = + callableFactory.createUnaryCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.listPatchJobInstanceDetailsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.createPatchDeploymentCallable = + callableFactory.createUnaryCallable( + createPatchDeploymentTransportSettings, + settings.createPatchDeploymentSettings(), + clientContext); + this.getPatchDeploymentCallable = + callableFactory.createUnaryCallable( + getPatchDeploymentTransportSettings, + settings.getPatchDeploymentSettings(), + clientContext); + this.listPatchDeploymentsCallable = + callableFactory.createUnaryCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.listPatchDeploymentsPagedCallable = + callableFactory.createPagedCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.deletePatchDeploymentCallable = + callableFactory.createUnaryCallable( + deletePatchDeploymentTransportSettings, + settings.deletePatchDeploymentSettings(), + clientContext); + this.updatePatchDeploymentCallable = + callableFactory.createUnaryCallable( + updatePatchDeploymentTransportSettings, + settings.updatePatchDeploymentSettings(), + clientContext); + this.pausePatchDeploymentCallable = + callableFactory.createUnaryCallable( + pausePatchDeploymentTransportSettings, + settings.pausePatchDeploymentSettings(), + clientContext); + this.resumePatchDeploymentCallable = + callableFactory.createUnaryCallable( + resumePatchDeploymentTransportSettings, + settings.resumePatchDeploymentSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(executePatchJobMethodDescriptor); + methodDescriptors.add(getPatchJobMethodDescriptor); + methodDescriptors.add(cancelPatchJobMethodDescriptor); + methodDescriptors.add(listPatchJobsMethodDescriptor); + methodDescriptors.add(listPatchJobInstanceDetailsMethodDescriptor); + methodDescriptors.add(createPatchDeploymentMethodDescriptor); + methodDescriptors.add(getPatchDeploymentMethodDescriptor); + methodDescriptors.add(listPatchDeploymentsMethodDescriptor); + methodDescriptors.add(deletePatchDeploymentMethodDescriptor); + methodDescriptors.add(updatePatchDeploymentMethodDescriptor); + methodDescriptors.add(pausePatchDeploymentMethodDescriptor); + methodDescriptors.add(resumePatchDeploymentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + executePatchJobCallable() { + return executePatchJobCallable; + } + + @Override + public UnaryCallable getPatchJobCallable() { + return getPatchJobCallable; + } + + @Override + public UnaryCallable + cancelPatchJobCallable() { + return cancelPatchJobCallable; + } + + @Override + public UnaryCallable + listPatchJobsCallable() { + return listPatchJobsCallable; + } + + @Override + public UnaryCallable + listPatchJobsPagedCallable() { + return listPatchJobsPagedCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable() { + return listPatchJobInstanceDetailsCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable() { + return listPatchJobInstanceDetailsPagedCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable() { + return createPatchDeploymentCallable; + } + + @Override + public UnaryCallable + getPatchDeploymentCallable() { + return getPatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable() { + return listPatchDeploymentsCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable() { + return listPatchDeploymentsPagedCallable; + } + + @Override + public UnaryCallable + deletePatchDeploymentCallable() { + return deletePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable() { + return updatePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable() { + return pausePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable() { + return resumePatchDeploymentCallable; + } + + @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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.java new file mode 100644 index 000000000000..d5b8ad3361dd --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.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.osconfig.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 OsConfigZonalService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigZonalServiceCallableFactory + 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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java new file mode 100644 index 000000000000..dcb753e28ba0 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java @@ -0,0 +1,1004 @@ +/* + * 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.osconfig.v1.stub; + +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.HttpJsonOperationSnapshot; +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.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.GetInventoryRequest; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.ListInventoriesResponse; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.longrunning.Operation; +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 OsConfigZonalService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigZonalServiceStub extends OsConfigZonalServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OSPolicyAssignmentOperationMetadata.getDescriptor()) + .add(OSPolicyAssignment.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/CreateOSPolicyAssignment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/osPolicyAssignments", + 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, "osPolicyAssignmentId", request.getOsPolicyAssignmentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/UpdateOSPolicyAssignment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{osPolicyAssignment.name=projects/*/locations/*/osPolicyAssignments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "osPolicyAssignment.name", + request.getOsPolicyAssignment().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("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}", + 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(OSPolicyAssignment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentsRequest, ListOSPolicyAssignmentsResponse> + listOSPolicyAssignmentsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/osPolicyAssignments", + 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(ListOSPolicyAssignmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentRevisions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions", + 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(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance( + ListOSPolicyAssignmentRevisionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/DeleteOSPolicyAssignment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + GetOSPolicyAssignmentReportRequest, OSPolicyAssignmentReport> + getOSPolicyAssignmentReportMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignmentReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}", + 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(OSPolicyAssignmentReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports", + 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( + ListOSPolicyAssignmentReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigZonalService/GetInventory") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*/inventory}", + 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(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Inventory.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigZonalService/ListInventories") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/instances/*}/inventories", + 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()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInventoriesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getVulnerabilityReportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/GetVulnerabilityReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*/vulnerabilityReport}", + 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(VulnerabilityReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsResponse> + listVulnerabilityReportsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListVulnerabilityReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports", + 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(ListVulnerabilityReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createOSPolicyAssignmentCallable; + private final OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable; + private final UnaryCallable + updateOSPolicyAssignmentCallable; + private final OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getOSPolicyAssignmentCallable; + private final UnaryCallable + listOSPolicyAssignmentsCallable; + private final UnaryCallable + listOSPolicyAssignmentsPagedCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable; + private final UnaryCallable + deleteOSPolicyAssignmentCallable; + private final OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getOSPolicyAssignmentReportCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable; + private final UnaryCallable getInventoryCallable; + private final UnaryCallable + listInventoriesCallable; + private final UnaryCallable + listInventoriesPagedCallable; + private final UnaryCallable + getVulnerabilityReportCallable; + private final UnaryCallable + listVulnerabilityReportsCallable; + private final UnaryCallable< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsPagedResponse> + listVulnerabilityReportsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigZonalServiceStub create( + OsConfigZonalServiceStubSettings settings) throws IOException { + return new HttpJsonOsConfigZonalServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigZonalServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigZonalServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigZonalServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + createOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listOSPolicyAssignmentsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentRevisionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentReportTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getVulnerabilityReportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVulnerabilityReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listVulnerabilityReportsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listVulnerabilityReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentSettings(), + clientContext); + this.createOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentSettings(), + clientContext); + this.updateOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentTransportSettings, + settings.getOSPolicyAssignmentSettings(), + clientContext); + this.listOSPolicyAssignmentsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.deleteOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentSettings(), + clientContext); + this.deleteOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getOSPolicyAssignmentReportCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentReportTransportSettings, + settings.getOSPolicyAssignmentReportSettings(), + clientContext); + this.listOSPolicyAssignmentReportsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.listOSPolicyAssignmentReportsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.getInventoryCallable = + callableFactory.createUnaryCallable( + getInventoryTransportSettings, settings.getInventorySettings(), clientContext); + this.listInventoriesCallable = + callableFactory.createUnaryCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.listInventoriesPagedCallable = + callableFactory.createPagedCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.getVulnerabilityReportCallable = + callableFactory.createUnaryCallable( + getVulnerabilityReportTransportSettings, + settings.getVulnerabilityReportSettings(), + clientContext); + this.listVulnerabilityReportsCallable = + callableFactory.createUnaryCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + this.listVulnerabilityReportsPagedCallable = + callableFactory.createPagedCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(updateOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentsMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentRevisionsMethodDescriptor); + methodDescriptors.add(deleteOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentReportMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentReportsMethodDescriptor); + methodDescriptors.add(getInventoryMethodDescriptor); + methodDescriptors.add(listInventoriesMethodDescriptor); + methodDescriptors.add(getVulnerabilityReportMethodDescriptor); + methodDescriptors.add(listVulnerabilityReportsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + createOSPolicyAssignmentCallable() { + return createOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable() { + return createOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + updateOSPolicyAssignmentCallable() { + return updateOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable() { + return updateOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentCallable() { + return getOSPolicyAssignmentCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsCallable() { + return listOSPolicyAssignmentsCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsPagedCallable() { + return listOSPolicyAssignmentsPagedCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable() { + return listOSPolicyAssignmentRevisionsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable() { + return listOSPolicyAssignmentRevisionsPagedCallable; + } + + @Override + public UnaryCallable + deleteOSPolicyAssignmentCallable() { + return deleteOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable() { + return deleteOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentReportCallable() { + return getOSPolicyAssignmentReportCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentReportsCallable() { + return listOSPolicyAssignmentReportsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable() { + return listOSPolicyAssignmentReportsPagedCallable; + } + + @Override + public UnaryCallable getInventoryCallable() { + return getInventoryCallable; + } + + @Override + public UnaryCallable listInventoriesCallable() { + return listInventoriesCallable; + } + + @Override + public UnaryCallable + listInventoriesPagedCallable() { + return listInventoriesPagedCallable; + } + + @Override + public UnaryCallable + getVulnerabilityReportCallable() { + return getVulnerabilityReportCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsCallable() { + return listVulnerabilityReportsCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsPagedCallable() { + return listVulnerabilityReportsPagedCallable; + } + + @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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java index 1b9e64cfc683..b3bc7fbea5ce 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java @@ -29,6 +29,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; @@ -455,6 +458,11 @@ public OsConfigServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -487,18 +495,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(OsConfigServiceStubSettings.class)) @@ -506,11 +521,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(OsConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigServiceStubSettings.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); @@ -696,6 +730,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 .executePatchJobSettings() diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java index 9a2a1ba7b8b8..5ea80e639a95 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java @@ -62,7 +62,11 @@ public abstract class OsConfigZonalServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public OperationCallable< diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java index 0b08206a13ca..d424cef305a8 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java @@ -32,6 +32,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +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.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -645,6 +648,11 @@ public OsConfigZonalServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigZonalServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigZonalServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -677,18 +685,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(OsConfigZonalServiceStubSettings.class)) @@ -696,11 +711,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(OsConfigZonalServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigZonalServiceStubSettings.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); @@ -920,6 +954,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 .createOSPolicyAssignmentSettings() diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java index 1dd4b87828e4..195a5deb9bd4 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.osconfig.v1alpha.stub.OsConfigZonalServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -111,6 +111,21 @@ * OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); * } * + *

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.
+ * OsConfigZonalServiceSettings osConfigZonalServiceSettings =
+ *     OsConfigZonalServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigZonalServiceClient osConfigZonalServiceClient =
+ *     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -118,7 +133,8 @@ public class OsConfigZonalServiceClient implements BackgroundResource { private final OsConfigZonalServiceSettings settings; private final OsConfigZonalServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of OsConfigZonalServiceClient with default settings. */ public static final OsConfigZonalServiceClient create() throws IOException { @@ -150,13 +166,17 @@ public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub s protected OsConfigZonalServiceClient(OsConfigZonalServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((OsConfigZonalServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected OsConfigZonalServiceClient(OsConfigZonalServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final OsConfigZonalServiceSettings getSettings() { @@ -171,10 +191,18 @@ public OsConfigZonalServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create an OS policy assignment. diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java index 6104e552dbc2..6fab56d7eca1 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java @@ -28,6 +28,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; @@ -248,11 +249,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigZonalServiceStubSettings.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 OsConfigZonalServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigZonalServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigZonalServiceStubSettings.defaultTransportChannelProvider(); } @@ -262,11 +270,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigZonalServiceStubSettings.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); @@ -305,6 +319,11 @@ private static Builder createDefault() { return new Builder(OsConfigZonalServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigZonalServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigZonalServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigZonalServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.java new file mode 100644 index 000000000000..3713cf217fd5 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.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.osconfig.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 OsConfigZonalService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigZonalServiceCallableFactory + 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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java new file mode 100644 index 000000000000..31ff24fd53c4 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java @@ -0,0 +1,1150 @@ +/* + * 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.osconfig.v1alpha.stub; + +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInstanceOSPoliciesCompliancesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.HttpJsonOperationSnapshot; +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.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest; +import com.google.cloud.osconfig.v1alpha.GetInventoryRequest; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesResponse; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.ListInventoriesResponse; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.longrunning.Operation; +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 OsConfigZonalService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigZonalServiceStub extends OsConfigZonalServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OSPolicyAssignmentOperationMetadata.getDescriptor()) + .add(OSPolicyAssignment.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/CreateOSPolicyAssignment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments", + 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, "osPolicyAssignmentId", request.getOsPolicyAssignmentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/UpdateOSPolicyAssignment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{osPolicyAssignment.name=projects/*/locations/*/osPolicyAssignments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "osPolicyAssignment.name", + request.getOsPolicyAssignment().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("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}", + 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(OSPolicyAssignment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentsRequest, ListOSPolicyAssignmentsResponse> + listOSPolicyAssignmentsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments", + 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(ListOSPolicyAssignmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentRevisions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions", + 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(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance( + ListOSPolicyAssignmentRevisionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/DeleteOSPolicyAssignment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + GetInstanceOSPoliciesComplianceRequest, InstanceOSPoliciesCompliance> + getInstanceOSPoliciesComplianceMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInstanceOSPoliciesCompliance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instanceOSPoliciesCompliances/*}", + 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(InstanceOSPoliciesCompliance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInstanceOSPoliciesCompliances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/instanceOSPoliciesCompliances", + 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( + ListInstanceOSPoliciesCompliancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GetOSPolicyAssignmentReportRequest, OSPolicyAssignmentReport> + getOSPolicyAssignmentReportMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignmentReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}", + 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(OSPolicyAssignmentReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports", + 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( + ListOSPolicyAssignmentReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInventory") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instances/*/inventory}", + 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(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Inventory.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInventories") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/instances/*}/inventories", + 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()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInventoriesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getVulnerabilityReportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetVulnerabilityReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instances/*/vulnerabilityReport}", + 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(VulnerabilityReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsResponse> + listVulnerabilityReportsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListVulnerabilityReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports", + 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(ListVulnerabilityReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createOSPolicyAssignmentCallable; + private final OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable; + private final UnaryCallable + updateOSPolicyAssignmentCallable; + private final OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getOSPolicyAssignmentCallable; + private final UnaryCallable + listOSPolicyAssignmentsCallable; + private final UnaryCallable + listOSPolicyAssignmentsPagedCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable; + private final UnaryCallable + deleteOSPolicyAssignmentCallable; + private final OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getInstanceOSPoliciesComplianceCallable; + private final UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesCallable; + private final UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesPagedResponse> + listInstanceOSPoliciesCompliancesPagedCallable; + private final UnaryCallable + getOSPolicyAssignmentReportCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable; + private final UnaryCallable getInventoryCallable; + private final UnaryCallable + listInventoriesCallable; + private final UnaryCallable + listInventoriesPagedCallable; + private final UnaryCallable + getVulnerabilityReportCallable; + private final UnaryCallable + listVulnerabilityReportsCallable; + private final UnaryCallable< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsPagedResponse> + listVulnerabilityReportsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigZonalServiceStub create( + OsConfigZonalServiceStubSettings settings) throws IOException { + return new HttpJsonOsConfigZonalServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigZonalServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigZonalServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigZonalServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + createOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listOSPolicyAssignmentsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentRevisionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getInstanceOSPoliciesComplianceTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getInstanceOSPoliciesComplianceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listInstanceOSPoliciesCompliancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentReportTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getVulnerabilityReportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVulnerabilityReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listVulnerabilityReportsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listVulnerabilityReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentSettings(), + clientContext); + this.createOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentSettings(), + clientContext); + this.updateOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentTransportSettings, + settings.getOSPolicyAssignmentSettings(), + clientContext); + this.listOSPolicyAssignmentsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.deleteOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentSettings(), + clientContext); + this.deleteOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getInstanceOSPoliciesComplianceCallable = + callableFactory.createUnaryCallable( + getInstanceOSPoliciesComplianceTransportSettings, + settings.getInstanceOSPoliciesComplianceSettings(), + clientContext); + this.listInstanceOSPoliciesCompliancesCallable = + callableFactory.createUnaryCallable( + listInstanceOSPoliciesCompliancesTransportSettings, + settings.listInstanceOSPoliciesCompliancesSettings(), + clientContext); + this.listInstanceOSPoliciesCompliancesPagedCallable = + callableFactory.createPagedCallable( + listInstanceOSPoliciesCompliancesTransportSettings, + settings.listInstanceOSPoliciesCompliancesSettings(), + clientContext); + this.getOSPolicyAssignmentReportCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentReportTransportSettings, + settings.getOSPolicyAssignmentReportSettings(), + clientContext); + this.listOSPolicyAssignmentReportsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.listOSPolicyAssignmentReportsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.getInventoryCallable = + callableFactory.createUnaryCallable( + getInventoryTransportSettings, settings.getInventorySettings(), clientContext); + this.listInventoriesCallable = + callableFactory.createUnaryCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.listInventoriesPagedCallable = + callableFactory.createPagedCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.getVulnerabilityReportCallable = + callableFactory.createUnaryCallable( + getVulnerabilityReportTransportSettings, + settings.getVulnerabilityReportSettings(), + clientContext); + this.listVulnerabilityReportsCallable = + callableFactory.createUnaryCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + this.listVulnerabilityReportsPagedCallable = + callableFactory.createPagedCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(updateOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentsMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentRevisionsMethodDescriptor); + methodDescriptors.add(deleteOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getInstanceOSPoliciesComplianceMethodDescriptor); + methodDescriptors.add(listInstanceOSPoliciesCompliancesMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentReportMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentReportsMethodDescriptor); + methodDescriptors.add(getInventoryMethodDescriptor); + methodDescriptors.add(listInventoriesMethodDescriptor); + methodDescriptors.add(getVulnerabilityReportMethodDescriptor); + methodDescriptors.add(listVulnerabilityReportsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + createOSPolicyAssignmentCallable() { + return createOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable() { + return createOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + updateOSPolicyAssignmentCallable() { + return updateOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable() { + return updateOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentCallable() { + return getOSPolicyAssignmentCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsCallable() { + return listOSPolicyAssignmentsCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsPagedCallable() { + return listOSPolicyAssignmentsPagedCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable() { + return listOSPolicyAssignmentRevisionsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable() { + return listOSPolicyAssignmentRevisionsPagedCallable; + } + + @Override + public UnaryCallable + deleteOSPolicyAssignmentCallable() { + return deleteOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable() { + return deleteOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getInstanceOSPoliciesComplianceCallable() { + return getInstanceOSPoliciesComplianceCallable; + } + + @Override + public UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesCallable() { + return listInstanceOSPoliciesCompliancesCallable; + } + + @Override + public UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesPagedResponse> + listInstanceOSPoliciesCompliancesPagedCallable() { + return listInstanceOSPoliciesCompliancesPagedCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentReportCallable() { + return getOSPolicyAssignmentReportCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentReportsCallable() { + return listOSPolicyAssignmentReportsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable() { + return listOSPolicyAssignmentReportsPagedCallable; + } + + @Override + public UnaryCallable getInventoryCallable() { + return getInventoryCallable; + } + + @Override + public UnaryCallable listInventoriesCallable() { + return listInventoriesCallable; + } + + @Override + public UnaryCallable + listInventoriesPagedCallable() { + return listInventoriesPagedCallable; + } + + @Override + public UnaryCallable + getVulnerabilityReportCallable() { + return getVulnerabilityReportCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsCallable() { + return listVulnerabilityReportsCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsPagedCallable() { + return listVulnerabilityReportsPagedCallable; + } + + @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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java index adf31c79d31e..62b2aebe1751 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java @@ -69,7 +69,11 @@ public abstract class OsConfigZonalServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public OperationCallable< diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java index 16e8b6227c47..02d35ba7738e 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java @@ -33,6 +33,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +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.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -766,6 +769,11 @@ public OsConfigZonalServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigZonalServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigZonalServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -798,18 +806,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(OsConfigZonalServiceStubSettings.class)) @@ -817,11 +832,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(OsConfigZonalServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigZonalServiceStubSettings.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); @@ -1064,6 +1098,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 .createOSPolicyAssignmentSettings() diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java index 8e1f953a2342..bbf2fb0e12f9 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java @@ -115,6 +115,21 @@ * OsConfigServiceClient.create(osConfigServiceSettings); * } * + *

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.
+ * OsConfigServiceSettings osConfigServiceSettings =
+ *     OsConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigServiceClient osConfigServiceClient =
+ *     OsConfigServiceClient.create(osConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java index 9fe9edc9a8ae..6d71245516b8 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.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; @@ -226,11 +227,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigServiceStubSettings.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 OsConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -240,11 +248,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigServiceStubSettings.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); @@ -282,6 +296,11 @@ private static Builder createDefault() { return new Builder(OsConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.java new file mode 100644 index 000000000000..c133333233d8 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.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.osconfig.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 OsConfigService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigServiceCallableFactory + 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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java new file mode 100644 index 000000000000..0e810d0c10dd --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java @@ -0,0 +1,1311 @@ +/* + * 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.osconfig.v1beta.stub; + +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListGuestPoliciesPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.cloud.osconfig.v1beta.PatchJobs; +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 OsConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigServiceStub extends OsConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + executePatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/ExecutePatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchJobs:execute", + 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("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/GetPatchJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchJobs/*}", + 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(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/CancelPatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchJobs/*}:cancel", + 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(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobsRequest, PatchJobs.ListPatchJobsResponse> + listPatchJobsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/ListPatchJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchJobs", + 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(PatchJobs.ListPatchJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/ListPatchJobInstanceDetails") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{parent=projects/*/patchJobs/*}/instanceDetails", + 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( + PatchJobs.ListPatchJobInstanceDetailsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/CreatePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchDeployments", + 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, "patchDeploymentId", request.getPatchDeploymentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/GetPatchDeployment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/ListPatchDeployments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchDeployments", + 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( + PatchDeployments.ListPatchDeploymentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deletePatchDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/DeletePatchDeployment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}", + 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< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/UpdatePatchDeployment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{patchDeployment.name=projects/*/patchDeployments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "patchDeployment.name", + request.getPatchDeployment().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("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/PausePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}:pause", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/ResumePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}:resume", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.CreateGuestPolicyRequest, GuestPolicies.GuestPolicy> + createGuestPolicyMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/CreateGuestPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/guestPolicies", + 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, "guestPolicyId", request.getGuestPolicyId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("guestPolicy", request.getGuestPolicy())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GuestPolicies.GuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.GetGuestPolicyRequest, GuestPolicies.GuestPolicy> + getGuestPolicyMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/GetGuestPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/guestPolicies/*}", + 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(GuestPolicies.GuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/ListGuestPolicies") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/guestPolicies", + 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( + GuestPolicies.ListGuestPoliciesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.UpdateGuestPolicyRequest, GuestPolicies.GuestPolicy> + updateGuestPolicyMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/UpdateGuestPolicy") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{guestPolicy.name=projects/*/guestPolicies/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "guestPolicy.name", request.getGuestPolicy().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("guestPolicy", request.getGuestPolicy())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GuestPolicies.GuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteGuestPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/DeleteGuestPolicy") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/guestPolicies/*}", + 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< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/LookupEffectiveGuestPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{instance=projects/*/zones/*/instances/*}:lookupEffectiveGuestPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "instance", request.getInstance()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearInstance().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GuestPolicies.EffectiveGuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + executePatchJobCallable; + private final UnaryCallable getPatchJobCallable; + private final UnaryCallable + cancelPatchJobCallable; + private final UnaryCallable + listPatchJobsCallable; + private final UnaryCallable + listPatchJobsPagedCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable; + private final UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable; + private final UnaryCallable + deletePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable; + private final UnaryCallable + createGuestPolicyCallable; + private final UnaryCallable + getGuestPolicyCallable; + private final UnaryCallable< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesCallable; + private final UnaryCallable< + GuestPolicies.ListGuestPoliciesRequest, ListGuestPoliciesPagedResponse> + listGuestPoliciesPagedCallable; + private final UnaryCallable + updateGuestPolicyCallable; + private final UnaryCallable + deleteGuestPolicyCallable; + private final UnaryCallable< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigServiceStub create(OsConfigServiceStubSettings settings) + throws IOException { + return new HttpJsonOsConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + executePatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(executePatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + cancelPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listPatchJobsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listPatchJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchJobInstanceDetailsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(createPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(getPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchDeploymentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deletePatchDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(updatePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(pausePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(resumePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createGuestPolicyTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(createGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getGuestPolicyTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listGuestPoliciesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateGuestPolicyTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(updateGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteGuestPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(lookupEffectiveGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.executePatchJobCallable = + callableFactory.createUnaryCallable( + executePatchJobTransportSettings, settings.executePatchJobSettings(), clientContext); + this.getPatchJobCallable = + callableFactory.createUnaryCallable( + getPatchJobTransportSettings, settings.getPatchJobSettings(), clientContext); + this.cancelPatchJobCallable = + callableFactory.createUnaryCallable( + cancelPatchJobTransportSettings, settings.cancelPatchJobSettings(), clientContext); + this.listPatchJobsCallable = + callableFactory.createUnaryCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobInstanceDetailsCallable = + callableFactory.createUnaryCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.listPatchJobInstanceDetailsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.createPatchDeploymentCallable = + callableFactory.createUnaryCallable( + createPatchDeploymentTransportSettings, + settings.createPatchDeploymentSettings(), + clientContext); + this.getPatchDeploymentCallable = + callableFactory.createUnaryCallable( + getPatchDeploymentTransportSettings, + settings.getPatchDeploymentSettings(), + clientContext); + this.listPatchDeploymentsCallable = + callableFactory.createUnaryCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.listPatchDeploymentsPagedCallable = + callableFactory.createPagedCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.deletePatchDeploymentCallable = + callableFactory.createUnaryCallable( + deletePatchDeploymentTransportSettings, + settings.deletePatchDeploymentSettings(), + clientContext); + this.updatePatchDeploymentCallable = + callableFactory.createUnaryCallable( + updatePatchDeploymentTransportSettings, + settings.updatePatchDeploymentSettings(), + clientContext); + this.pausePatchDeploymentCallable = + callableFactory.createUnaryCallable( + pausePatchDeploymentTransportSettings, + settings.pausePatchDeploymentSettings(), + clientContext); + this.resumePatchDeploymentCallable = + callableFactory.createUnaryCallable( + resumePatchDeploymentTransportSettings, + settings.resumePatchDeploymentSettings(), + clientContext); + this.createGuestPolicyCallable = + callableFactory.createUnaryCallable( + createGuestPolicyTransportSettings, + settings.createGuestPolicySettings(), + clientContext); + this.getGuestPolicyCallable = + callableFactory.createUnaryCallable( + getGuestPolicyTransportSettings, settings.getGuestPolicySettings(), clientContext); + this.listGuestPoliciesCallable = + callableFactory.createUnaryCallable( + listGuestPoliciesTransportSettings, + settings.listGuestPoliciesSettings(), + clientContext); + this.listGuestPoliciesPagedCallable = + callableFactory.createPagedCallable( + listGuestPoliciesTransportSettings, + settings.listGuestPoliciesSettings(), + clientContext); + this.updateGuestPolicyCallable = + callableFactory.createUnaryCallable( + updateGuestPolicyTransportSettings, + settings.updateGuestPolicySettings(), + clientContext); + this.deleteGuestPolicyCallable = + callableFactory.createUnaryCallable( + deleteGuestPolicyTransportSettings, + settings.deleteGuestPolicySettings(), + clientContext); + this.lookupEffectiveGuestPolicyCallable = + callableFactory.createUnaryCallable( + lookupEffectiveGuestPolicyTransportSettings, + settings.lookupEffectiveGuestPolicySettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(executePatchJobMethodDescriptor); + methodDescriptors.add(getPatchJobMethodDescriptor); + methodDescriptors.add(cancelPatchJobMethodDescriptor); + methodDescriptors.add(listPatchJobsMethodDescriptor); + methodDescriptors.add(listPatchJobInstanceDetailsMethodDescriptor); + methodDescriptors.add(createPatchDeploymentMethodDescriptor); + methodDescriptors.add(getPatchDeploymentMethodDescriptor); + methodDescriptors.add(listPatchDeploymentsMethodDescriptor); + methodDescriptors.add(deletePatchDeploymentMethodDescriptor); + methodDescriptors.add(updatePatchDeploymentMethodDescriptor); + methodDescriptors.add(pausePatchDeploymentMethodDescriptor); + methodDescriptors.add(resumePatchDeploymentMethodDescriptor); + methodDescriptors.add(createGuestPolicyMethodDescriptor); + methodDescriptors.add(getGuestPolicyMethodDescriptor); + methodDescriptors.add(listGuestPoliciesMethodDescriptor); + methodDescriptors.add(updateGuestPolicyMethodDescriptor); + methodDescriptors.add(deleteGuestPolicyMethodDescriptor); + methodDescriptors.add(lookupEffectiveGuestPolicyMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + executePatchJobCallable() { + return executePatchJobCallable; + } + + @Override + public UnaryCallable getPatchJobCallable() { + return getPatchJobCallable; + } + + @Override + public UnaryCallable + cancelPatchJobCallable() { + return cancelPatchJobCallable; + } + + @Override + public UnaryCallable + listPatchJobsCallable() { + return listPatchJobsCallable; + } + + @Override + public UnaryCallable + listPatchJobsPagedCallable() { + return listPatchJobsPagedCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable() { + return listPatchJobInstanceDetailsCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable() { + return listPatchJobInstanceDetailsPagedCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable() { + return createPatchDeploymentCallable; + } + + @Override + public UnaryCallable + getPatchDeploymentCallable() { + return getPatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable() { + return listPatchDeploymentsCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable() { + return listPatchDeploymentsPagedCallable; + } + + @Override + public UnaryCallable + deletePatchDeploymentCallable() { + return deletePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable() { + return updatePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable() { + return pausePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable() { + return resumePatchDeploymentCallable; + } + + @Override + public UnaryCallable + createGuestPolicyCallable() { + return createGuestPolicyCallable; + } + + @Override + public UnaryCallable + getGuestPolicyCallable() { + return getGuestPolicyCallable; + } + + @Override + public UnaryCallable< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesCallable() { + return listGuestPoliciesCallable; + } + + @Override + public UnaryCallable + listGuestPoliciesPagedCallable() { + return listGuestPoliciesPagedCallable; + } + + @Override + public UnaryCallable + updateGuestPolicyCallable() { + return updateGuestPolicyCallable; + } + + @Override + public UnaryCallable deleteGuestPolicyCallable() { + return deleteGuestPolicyCallable; + } + + @Override + public UnaryCallable< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyCallable() { + return lookupEffectiveGuestPolicyCallable; + } + + @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/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java index bf1745b0c148..75c7b86185b2 100644 --- a/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java +++ b/java-os-config/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.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; @@ -592,6 +595,11 @@ public OsConfigServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -624,18 +632,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(OsConfigServiceStubSettings.class)) @@ -643,11 +658,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(OsConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigServiceStubSettings.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); @@ -883,6 +917,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 .executePatchJobSettings() diff --git a/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..739cb8607cff --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java @@ -0,0 +1,1242 @@ +/* + * 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.osconfig.v1; + +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.osconfig.v1.stub.HttpJsonOsConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +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 OsConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigServiceStub.getMethodDescriptors(), + OsConfigServiceSettings.getDefaultEndpoint()); + OsConfigServiceSettings settings = + OsConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void executePatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + + PatchJobs.PatchJob actualResponse = client.executePatchJob(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 executePatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + client.executePatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobName name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + + PatchJobs.PatchJob actualResponse = client.getPatchJob(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 getPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobName name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + client.getPatchJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchJobTest2() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3014/patchJobs/patchJob-3014"; + + PatchJobs.PatchJob actualResponse = client.getPatchJob(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 getPatchJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3014/patchJobs/patchJob-3014"; + client.getPatchJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + + PatchJobs.PatchJob actualResponse = client.cancelPatchJob(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 cancelPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + client.cancelPatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobsTest() throws Exception { + PatchJobs.PatchJob responsesElement = PatchJobs.PatchJob.newBuilder().build(); + PatchJobs.ListPatchJobsResponse expectedResponse = + PatchJobs.ListPatchJobsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListPatchJobsPagedResponse pagedListResponse = client.listPatchJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobsList().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 listPatchJobsExceptionTest() 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.listPatchJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobsTest2() throws Exception { + PatchJobs.PatchJob responsesElement = PatchJobs.PatchJob.newBuilder().build(); + PatchJobs.ListPatchJobsResponse expectedResponse = + PatchJobs.ListPatchJobsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListPatchJobsPagedResponse pagedListResponse = client.listPatchJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobsList().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 listPatchJobsExceptionTest2() 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.listPatchJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobInstanceDetailsTest() throws Exception { + PatchJobs.PatchJobInstanceDetails responsesElement = + PatchJobs.PatchJobInstanceDetails.newBuilder().build(); + PatchJobs.ListPatchJobInstanceDetailsResponse expectedResponse = + PatchJobs.ListPatchJobInstanceDetailsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobInstanceDetails(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobName parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + + ListPatchJobInstanceDetailsPagedResponse pagedListResponse = + client.listPatchJobInstanceDetails(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobInstanceDetailsList().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 listPatchJobInstanceDetailsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobName parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + client.listPatchJobInstanceDetails(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobInstanceDetailsTest2() throws Exception { + PatchJobs.PatchJobInstanceDetails responsesElement = + PatchJobs.PatchJobInstanceDetails.newBuilder().build(); + PatchJobs.ListPatchJobInstanceDetailsResponse expectedResponse = + PatchJobs.ListPatchJobInstanceDetailsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobInstanceDetails(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + + ListPatchJobInstanceDetailsPagedResponse pagedListResponse = + client.listPatchJobInstanceDetails(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobInstanceDetailsList().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 listPatchJobInstanceDetailsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + client.listPatchJobInstanceDetails(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + + PatchDeployments.PatchDeployment actualResponse = + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + 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 createPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + + PatchDeployments.PatchDeployment actualResponse = + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + 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 createPatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.getPatchDeployment(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 getPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.getPatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.getPatchDeployment(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 getPatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.getPatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchDeploymentsTest() throws Exception { + PatchDeployments.PatchDeployment responsesElement = + PatchDeployments.PatchDeployment.newBuilder().build(); + PatchDeployments.ListPatchDeploymentsResponse expectedResponse = + PatchDeployments.ListPatchDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListPatchDeploymentsPagedResponse pagedListResponse = client.listPatchDeployments(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchDeploymentsList().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 listPatchDeploymentsExceptionTest() 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.listPatchDeployments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchDeploymentsTest2() throws Exception { + PatchDeployments.PatchDeployment responsesElement = + PatchDeployments.PatchDeployment.newBuilder().build(); + PatchDeployments.ListPatchDeploymentsResponse expectedResponse = + PatchDeployments.ListPatchDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListPatchDeploymentsPagedResponse pagedListResponse = client.listPatchDeployments(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchDeploymentsList().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 listPatchDeploymentsExceptionTest2() 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.listPatchDeployments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePatchDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + client.deletePatchDeployment(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 deletePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.deletePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePatchDeploymentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + client.deletePatchDeployment(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 deletePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.deletePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updatePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + PatchDeployments.PatchDeployment actualResponse = + client.updatePatchDeployment(patchDeployment, 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 updatePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updatePatchDeployment(patchDeployment, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..3f5890234d10 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java @@ -0,0 +1,1359 @@ +/* + * 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.osconfig.v1; + +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.osconfig.v1.stub.HttpJsonOsConfigZonalServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +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.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +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 OsConfigZonalServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigZonalServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigZonalServiceStub.getMethodDescriptors(), + OsConfigZonalServiceSettings.getDefaultEndpoint()); + OsConfigZonalServiceSettings settings = + OsConfigZonalServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigZonalServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + 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 createOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + 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 createOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + OSPolicyAssignment actualResponse = + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + 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 updateOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteOSPolicyAssignmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + client.deleteOSPolicyAssignmentAsync(name).get(); + + 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 deleteOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteOSPolicyAssignmentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + client.deleteOSPolicyAssignmentAsync(name).get(); + + 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 deleteOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getOSPolicyAssignmentReportTest() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentReportTest2() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest2() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest2() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest2() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest2() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest2() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..44e3bfbabb59 --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java @@ -0,0 +1,1576 @@ +/* + * 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.osconfig.v1alpha; + +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInstanceOSPoliciesCompliancesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.osconfig.v1alpha.stub.HttpJsonOsConfigZonalServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +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.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +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 OsConfigZonalServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigZonalServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigZonalServiceStub.getMethodDescriptors(), + OsConfigZonalServiceSettings.getDefaultEndpoint()); + OsConfigZonalServiceSettings settings = + OsConfigZonalServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigZonalServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + 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 createOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + 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 createOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + OSPolicyAssignment actualResponse = + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + 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 updateOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteOSPolicyAssignmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + client.deleteOSPolicyAssignmentAsync(name).get(); + + 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 deleteOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteOSPolicyAssignmentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + client.deleteOSPolicyAssignmentAsync(name).get(); + + 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 deleteOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getInstanceOSPoliciesComplianceTest() throws Exception { + InstanceOSPoliciesCompliance expectedResponse = + InstanceOSPoliciesCompliance.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setInstance("instance555127957") + .setState(OSPolicyComplianceState.forNumber(0)) + .setDetailedState("detailedState1829498305") + .setDetailedStateReason("detailedStateReason-790407323") + .addAllOsPolicyCompliances( + new ArrayList()) + .setLastComplianceCheckTime(Timestamp.newBuilder().build()) + .setLastComplianceRunId("lastComplianceRunId168782901") + .build(); + mockService.addResponse(expectedResponse); + + InstanceOSPoliciesComplianceName name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + InstanceOSPoliciesCompliance actualResponse = client.getInstanceOSPoliciesCompliance(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 getInstanceOSPoliciesComplianceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceOSPoliciesComplianceName name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInstanceOSPoliciesCompliance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceOSPoliciesComplianceTest2() throws Exception { + InstanceOSPoliciesCompliance expectedResponse = + InstanceOSPoliciesCompliance.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setInstance("instance555127957") + .setState(OSPolicyComplianceState.forNumber(0)) + .setDetailedState("detailedState1829498305") + .setDetailedStateReason("detailedStateReason-790407323") + .addAllOsPolicyCompliances( + new ArrayList()) + .setLastComplianceCheckTime(Timestamp.newBuilder().build()) + .setLastComplianceRunId("lastComplianceRunId168782901") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1829/locations/location-1829/instanceOSPoliciesCompliances/instanceOSPoliciesCompliance-1829"; + + InstanceOSPoliciesCompliance actualResponse = client.getInstanceOSPoliciesCompliance(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 getInstanceOSPoliciesComplianceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1829/locations/location-1829/instanceOSPoliciesCompliances/instanceOSPoliciesCompliance-1829"; + client.getInstanceOSPoliciesCompliance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstanceOSPoliciesCompliancesTest() throws Exception { + InstanceOSPoliciesCompliance responsesElement = + InstanceOSPoliciesCompliance.newBuilder().build(); + ListInstanceOSPoliciesCompliancesResponse expectedResponse = + ListInstanceOSPoliciesCompliancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstanceOsPoliciesCompliances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListInstanceOSPoliciesCompliancesPagedResponse pagedListResponse = + client.listInstanceOSPoliciesCompliances(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getInstanceOsPoliciesCompliancesList().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 listInstanceOSPoliciesCompliancesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listInstanceOSPoliciesCompliances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstanceOSPoliciesCompliancesTest2() throws Exception { + InstanceOSPoliciesCompliance responsesElement = + InstanceOSPoliciesCompliance.newBuilder().build(); + ListInstanceOSPoliciesCompliancesResponse expectedResponse = + ListInstanceOSPoliciesCompliancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstanceOsPoliciesCompliances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListInstanceOSPoliciesCompliancesPagedResponse pagedListResponse = + client.listInstanceOSPoliciesCompliances(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getInstanceOsPoliciesCompliancesList().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 listInstanceOSPoliciesCompliancesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listInstanceOSPoliciesCompliances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentReportTest() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentReportTest2() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest2() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest2() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest2() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest2() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest2() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..bd55af09538e --- /dev/null +++ b/java-os-config/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java @@ -0,0 +1,1447 @@ +/* + * 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.osconfig.v1beta; + +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListGuestPoliciesPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.osconfig.v1beta.stub.HttpJsonOsConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Duration; +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 OsConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigServiceStub.getMethodDescriptors(), + OsConfigServiceSettings.getDefaultEndpoint()); + OsConfigServiceSettings settings = + OsConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void executePatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment("patchDeployment1500445997") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("projects/project-2353") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + + PatchJobs.PatchJob actualResponse = client.executePatchJob(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 executePatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("projects/project-2353") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + client.executePatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment("patchDeployment1500445997") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + + PatchJobs.PatchJob actualResponse = client.getPatchJob(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 getPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + client.getPatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment("patchDeployment1500445997") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + + PatchJobs.PatchJob actualResponse = client.cancelPatchJob(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 cancelPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + client.cancelPatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobsTest() throws Exception { + PatchJobs.PatchJob responsesElement = PatchJobs.PatchJob.newBuilder().build(); + PatchJobs.ListPatchJobsResponse expectedResponse = + PatchJobs.ListPatchJobsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + + ListPatchJobsPagedResponse pagedListResponse = client.listPatchJobs(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobsList().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 listPatchJobsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + client.listPatchJobs(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobInstanceDetailsTest() throws Exception { + PatchJobs.PatchJobInstanceDetails responsesElement = + PatchJobs.PatchJobInstanceDetails.newBuilder().build(); + PatchJobs.ListPatchJobInstanceDetailsResponse expectedResponse = + PatchJobs.ListPatchJobInstanceDetailsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobInstanceDetails(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + + ListPatchJobInstanceDetailsPagedResponse pagedListResponse = + client.listPatchJobInstanceDetails(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobInstanceDetailsList().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 listPatchJobInstanceDetailsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + client.listPatchJobInstanceDetails(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("projects/project-2353") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + + PatchDeployments.PatchDeployment actualResponse = client.createPatchDeployment(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 createPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("projects/project-2353") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + client.createPatchDeployment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + + PatchDeployments.PatchDeployment actualResponse = client.getPatchDeployment(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 getPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + client.getPatchDeployment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchDeploymentsTest() throws Exception { + PatchDeployments.PatchDeployment responsesElement = + PatchDeployments.PatchDeployment.newBuilder().build(); + PatchDeployments.ListPatchDeploymentsResponse expectedResponse = + PatchDeployments.ListPatchDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListPatchDeploymentsPagedResponse pagedListResponse = client.listPatchDeployments(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchDeploymentsList().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 listPatchDeploymentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listPatchDeployments(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePatchDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + + client.deletePatchDeployment(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 deletePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + client.deletePatchDeployment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updatePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + PatchDeployments.PatchDeployment actualResponse = + client.updatePatchDeployment(patchDeployment, 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 updatePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updatePatchDeployment(patchDeployment, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createGuestPolicyTest() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + + GuestPolicies.GuestPolicy actualResponse = client.createGuestPolicy(parent, guestPolicy); + 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 createGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + client.createGuestPolicy(parent, guestPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createGuestPolicyTest2() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + + GuestPolicies.GuestPolicy actualResponse = client.createGuestPolicy(parent, guestPolicy); + 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 createGuestPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + client.createGuestPolicy(parent, guestPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGuestPolicyTest() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + + GuestPolicies.GuestPolicy actualResponse = client.getGuestPolicy(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 getGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + client.getGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGuestPolicyTest2() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + + GuestPolicies.GuestPolicy actualResponse = client.getGuestPolicy(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 getGuestPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + client.getGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGuestPoliciesTest() throws Exception { + GuestPolicies.GuestPolicy responsesElement = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.ListGuestPoliciesResponse expectedResponse = + GuestPolicies.ListGuestPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllGuestPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListGuestPoliciesPagedResponse pagedListResponse = client.listGuestPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGuestPoliciesList().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 listGuestPoliciesExceptionTest() 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.listGuestPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGuestPoliciesTest2() throws Exception { + GuestPolicies.GuestPolicy responsesElement = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.ListGuestPoliciesResponse expectedResponse = + GuestPolicies.ListGuestPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllGuestPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListGuestPoliciesPagedResponse pagedListResponse = client.listGuestPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGuestPoliciesList().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 listGuestPoliciesExceptionTest2() 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.listGuestPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateGuestPolicyTest() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + GuestPolicies.GuestPolicy guestPolicy = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + GuestPolicies.GuestPolicy actualResponse = client.updateGuestPolicy(guestPolicy, 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 updateGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicies.GuestPolicy guestPolicy = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateGuestPolicy(guestPolicy, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGuestPolicyTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + + client.deleteGuestPolicy(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 deleteGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + client.deleteGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGuestPolicyTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + + client.deleteGuestPolicy(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 deleteGuestPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + client.deleteGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void lookupEffectiveGuestPolicyTest() throws Exception { + GuestPolicies.EffectiveGuestPolicy expectedResponse = + GuestPolicies.EffectiveGuestPolicy.newBuilder() + .addAllPackages(new ArrayList()) + .addAllPackageRepositories( + new ArrayList()) + .addAllSoftwareRecipes( + new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("projects/project-4489/zones/zone-4489/instances/instance-4489") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + + GuestPolicies.EffectiveGuestPolicy actualResponse = client.lookupEffectiveGuestPolicy(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 lookupEffectiveGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("projects/project-4489/zones/zone-4489/instances/instance-4489") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + client.lookupEffectiveGuestPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java new file mode 100644 index 000000000000..934a94703162 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class AsyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + asyncCancelPatchJob(); + } + + public static void asyncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.cancelPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java new file mode 100644 index 000000000000..6c80b7caeb74 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + syncCancelPatchJob(); + } + + public static void syncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.cancelPatchJob(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..7668a0a079f8 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..d450bea30f95 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; + +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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetEndpoint.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..fcca92851b0e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigserviceclient_create_setendpoint_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java new file mode 100644 index 000000000000..39b9b03f4ea6 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class AsyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncCreatePatchDeployment(); + } + + public static void asyncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.createPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java new file mode 100644 index 000000000000..ac0268aaba81 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeployment(); + } + + public static void syncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.java new file mode 100644 index 000000000000..193fc06903eb --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_projectnamepatchdeploymentspatchdeploymentstring_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString(); + } + + public static void syncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + } + } +} +// [END +// osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_projectnamepatchdeploymentspatchdeploymentstring_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.java new file mode 100644 index 000000000000..815c08b966d6 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_stringpatchdeploymentspatchdeploymentstring_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString(); + } + + public static void syncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + } + } +} +// [END +// osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_stringpatchdeploymentspatchdeploymentstring_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java new file mode 100644 index 000000000000..174646555df6 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.Empty; + +public class AsyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncDeletePatchDeployment(); + } + + public static void asyncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.deletePatchDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java new file mode 100644 index 000000000000..43f40e4bb143 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeployment(); + } + + public static void syncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + osConfigServiceClient.deletePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.java new file mode 100644 index 000000000000..689acfb34ec6 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; + +public class SyncDeletePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeploymentPatchdeploymentname(); + } + + public static void syncDeletePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + osConfigServiceClient.deletePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_patchdeploymentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.java new file mode 100644 index 000000000000..f0598470f22d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; + +public class SyncDeletePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeploymentString(); + } + + public static void syncDeletePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + osConfigServiceClient.deletePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java new file mode 100644 index 000000000000..99e1d52168bb --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java @@ -0,0 +1,54 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_executepatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.protobuf.Duration; + +public class AsyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + asyncExecutePatchJob(); + } + + public static void asyncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.executePatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_executepatchjob_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 000000000000..f01e3d0d5c7a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_executepatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.protobuf.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.executePatchJob(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_executepatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java new file mode 100644 index 000000000000..f2566ae9defd --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class AsyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + asyncGetPatchDeployment(); + } + + public static void asyncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.getPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java new file mode 100644 index 000000000000..9730eb8aef58 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + syncGetPatchDeployment(); + } + + public static void syncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.java new file mode 100644 index 000000000000..e8b7086ed201 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncGetPatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncGetPatchDeploymentPatchdeploymentname(); + } + + public static void syncGetPatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_patchdeploymentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.java new file mode 100644 index 000000000000..544cc078d7cd --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncGetPatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncGetPatchDeploymentString(); + } + + public static void syncGetPatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java new file mode 100644 index 000000000000..9898a3221f86 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class AsyncGetPatchJob { + + public static void main(String[] args) throws Exception { + asyncGetPatchJob(); + } + + public static void asyncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.getPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java new file mode 100644 index 000000000000..d230cb8a75b2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncGetPatchJob { + + public static void main(String[] args) throws Exception { + syncGetPatchJob(); + } + + public static void syncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.java new file mode 100644 index 000000000000..d82c080823d3 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_patchjobname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncGetPatchJobPatchjobname { + + public static void main(String[] args) throws Exception { + syncGetPatchJobPatchjobname(); + } + + public static void syncGetPatchJobPatchjobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobName name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_patchjobname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.java new file mode 100644 index 000000000000..d0906ecd51c1 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncGetPatchJobString { + + public static void main(String[] args) throws Exception { + syncGetPatchJobString(); + } + + public static void syncGetPatchJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString(); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java new file mode 100644 index 000000000000..713f2d2e105d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class AsyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + asyncListPatchDeployments(); + } + + public static void asyncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchDeploymentsPagedCallable().futureCall(request); + // Do something. + for (PatchDeployments.PatchDeployment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java new file mode 100644 index 000000000000..bbdc4fca7743 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java @@ -0,0 +1,57 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_paged_async] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListPatchDeploymentsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchDeploymentsPaged(); + } + + public static void asyncListPatchDeploymentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + PatchDeployments.ListPatchDeploymentsResponse response = + osConfigServiceClient.listPatchDeploymentsCallable().call(request); + for (PatchDeployments.PatchDeployment element : response.getPatchDeploymentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java new file mode 100644 index 000000000000..fe538800d13b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + syncListPatchDeployments(); + } + + public static void syncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.java new file mode 100644 index 000000000000..06763d3c1bd9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_projectname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchDeploymentsProjectname { + + public static void main(String[] args) throws Exception { + syncListPatchDeploymentsProjectname(); + } + + public static void syncListPatchDeploymentsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_projectname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.java new file mode 100644 index 000000000000..5c2d21e94a31 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchDeploymentsString { + + public static void main(String[] args) throws Exception { + syncListPatchDeploymentsString(); + } + + public static void syncListPatchDeploymentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java new file mode 100644 index 000000000000..3c98250c3565 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class AsyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetails(); + } + + public static void asyncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobInstanceDetailsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJobInstanceDetails element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java new file mode 100644 index 000000000000..11b1548246f8 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.common.base.Strings; + +public class AsyncListPatchJobInstanceDetailsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetailsPaged(); + } + + public static void asyncListPatchJobInstanceDetailsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobInstanceDetailsResponse response = + osConfigServiceClient.listPatchJobInstanceDetailsCallable().call(request); + for (PatchJobs.PatchJobInstanceDetails element : + response.getPatchJobInstanceDetailsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java new file mode 100644 index 000000000000..a8369c4159af --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetails(); + } + + public static void syncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.java new file mode 100644 index 000000000000..721de14ca228 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_patchjobname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncListPatchJobInstanceDetailsPatchjobname { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetailsPatchjobname(); + } + + public static void syncListPatchJobInstanceDetailsPatchjobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobName parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_patchjobname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java new file mode 100644 index 000000000000..f8c62abdcc0d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncListPatchJobInstanceDetailsString { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetailsString(); + } + + public static void syncListPatchJobInstanceDetailsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString(); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java new file mode 100644 index 000000000000..903aaa26cf15 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class AsyncListPatchJobs { + + public static void main(String[] args) throws Exception { + asyncListPatchJobs(); + } + + public static void asyncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJob element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java new file mode 100644 index 000000000000..a983ff626d8b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_paged_async] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListPatchJobsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobsPaged(); + } + + public static void asyncListPatchJobsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobsResponse response = + osConfigServiceClient.listPatchJobsCallable().call(request); + for (PatchJobs.PatchJob element : response.getPatchJobsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java new file mode 100644 index 000000000000..c65234d5f2c4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchJobs { + + public static void main(String[] args) throws Exception { + syncListPatchJobs(); + } + + public static void syncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.java new file mode 100644 index 000000000000..c6b6d9772f1c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_projectname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchJobsProjectname { + + public static void main(String[] args) throws Exception { + syncListPatchJobsProjectname(); + } + + public static void syncListPatchJobsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_projectname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.java new file mode 100644 index 000000000000..93e9250f1b19 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchJobsString { + + public static void main(String[] args) throws Exception { + syncListPatchJobsString(); + } + + public static void syncListPatchJobsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java new file mode 100644 index 000000000000..afc3ea19c876 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class AsyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncPausePatchDeployment(); + } + + public static void asyncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.pausePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java new file mode 100644 index 000000000000..bc0399c3e896 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + syncPausePatchDeployment(); + } + + public static void syncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.pausePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java new file mode 100644 index 000000000000..a92d2955aec4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncPausePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentPatchdeploymentname(); + } + + public static void syncPausePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java new file mode 100644 index 000000000000..d7a30e346384 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncPausePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentString(); + } + + public static void syncPausePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java new file mode 100644 index 000000000000..939fdc4a6d8e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class AsyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncResumePatchDeployment(); + } + + public static void asyncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.resumePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java new file mode 100644 index 000000000000..0238f217e06d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + syncResumePatchDeployment(); + } + + public static void syncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.resumePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java new file mode 100644 index 000000000000..20aae25d8d17 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncResumePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentPatchdeploymentname(); + } + + public static void syncResumePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java new file mode 100644 index 000000000000..350233d7708f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncResumePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentString(); + } + + public static void syncResumePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java new file mode 100644 index 000000000000..e395bcfee88f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class AsyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncUpdatePatchDeployment(); + } + + public static void asyncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.updatePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java new file mode 100644 index 000000000000..87ec085c4709 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeployment(); + } + + public static void syncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java new file mode 100644 index 000000000000..d00293fd743e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask(); + } + + public static void syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(patchDeployment, updateMask); + } + } +} +// [END +// osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 000000000000..a94e26010eb7 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigservicesettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigservicesettings_executepatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..ab5bad569635 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..7b15dcea7aed --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; + +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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..20560c38364e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_create_setendpoint_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java new file mode 100644 index 000000000000..b29015deb222 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignment(); + } + + public static void asyncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + ApiFuture future = + osConfigZonalServiceClient.createOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java new file mode 100644 index 000000000000..3eee2c2723e2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncCreateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignmentLRO(); + } + + public static void asyncCreateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OperationFuture future = + osConfigZonalServiceClient + .createOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java new file mode 100644 index 000000000000..5ab163dba385 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_sync] +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignment(); + } + + public static void syncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.createOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java new file mode 100644 index 000000000000..b0f03617c1d5 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java new file mode 100644 index 000000000000..a6b01a70deaa --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentStringOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentStringOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentStringOspolicyassignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java new file mode 100644 index 000000000000..dc5706d4bf90 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignment(); + } + + public static void asyncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.deleteOSPolicyAssignmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java new file mode 100644 index 000000000000..f156c32cd568 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignmentLRO(); + } + + public static void asyncDeleteOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .deleteOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java new file mode 100644 index 000000000000..0fa8ef79d360 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignment(); + } + + public static void syncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 000000000000..1e9be5cd3367 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncDeleteOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncDeleteOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java new file mode 100644 index 000000000000..0304f6230523 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncDeleteOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentString(); + } + + public static void syncDeleteOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java new file mode 100644 index 000000000000..fa59f18e1aa5 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetInventoryRequest; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncGetInventory { + + public static void main(String[] args) throws Exception { + asyncGetInventory(); + } + + public static void asyncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getInventoryCallable().futureCall(request); + // Do something. + Inventory response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.java new file mode 100644 index 000000000000..9062f4d63c98 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_sync] +import com.google.cloud.osconfig.v1.GetInventoryRequest; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetInventory { + + public static void main(String[] args) throws Exception { + syncGetInventory(); + } + + public static void syncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + Inventory response = osConfigZonalServiceClient.getInventory(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java new file mode 100644 index 000000000000..32f4558569c2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetInventoryInventoryname { + + public static void main(String[] args) throws Exception { + syncGetInventoryInventoryname(); + } + + public static void syncGetInventoryInventoryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java new file mode 100644 index 000000000000..85e4f87d624e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_string_sync] +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetInventoryString { + + public static void main(String[] args) throws Exception { + syncGetInventoryString(); + } + + public static void syncGetInventoryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..ca2dec87cf81 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignment(); + } + + public static void asyncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentCallable().futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..6bbf46e28cb0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 000000000000..90531eafcacf --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncGetOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java new file mode 100644 index 000000000000..2904b57eb946 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentString(); + } + + public static void syncGetOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java new file mode 100644 index 000000000000..f88f717a2371 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignmentReport(); + } + + public static void asyncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentReportCallable().futureCall(request); + // Do something. + OSPolicyAssignmentReport response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java new file mode 100644 index 000000000000..59fce3bab42c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReport(); + } + + public static void syncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java new file mode 100644 index 000000000000..0b0b82d84b62 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportOspolicyassignmentreportname(); + } + + public static void syncGetOSPolicyAssignmentReportOspolicyassignmentreportname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java new file mode 100644 index 000000000000..2f823797a0a2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportString(); + } + + public static void syncGetOSPolicyAssignmentReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java new file mode 100644 index 000000000000..fff8c73274b9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java @@ -0,0 +1,49 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class AsyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + asyncGetVulnerabilityReport(); + } + + public static void asyncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getVulnerabilityReportCallable().futureCall(request); + // Do something. + VulnerabilityReport response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java new file mode 100644 index 000000000000..1ebdcfd36620 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] +import com.google.cloud.osconfig.v1.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class SyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReport(); + } + + public static void syncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java new file mode 100644 index 000000000000..15ab78a0fb1f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportString { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportString(); + } + + public static void syncGetVulnerabilityReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java new file mode 100644 index 000000000000..7638d792f28f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportVulnerabilityreportname { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportVulnerabilityreportname(); + } + + public static void syncGetVulnerabilityReportVulnerabilityreportname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.java new file mode 100644 index 000000000000..e2baa96ed401 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListInventories { + + public static void main(String[] args) throws Exception { + asyncListInventories(); + } + + public static void asyncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listInventoriesPagedCallable().futureCall(request); + // Do something. + for (Inventory element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java new file mode 100644 index 000000000000..65e897265c97 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java @@ -0,0 +1,66 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_paged_async] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.ListInventoriesResponse; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListInventoriesPaged { + + public static void main(String[] args) throws Exception { + asyncListInventoriesPaged(); + } + + public static void asyncListInventoriesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInventoriesResponse response = + osConfigZonalServiceClient.listInventoriesCallable().call(request); + for (Inventory element : response.getInventoriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java new file mode 100644 index 000000000000..41eb7381ba40 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java @@ -0,0 +1,54 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListInventories { + + public static void main(String[] args) throws Exception { + syncListInventories(); + } + + public static void syncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Inventory element : osConfigZonalServiceClient.listInventories(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java new file mode 100644 index 000000000000..bf915c60775d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_instancename_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListInventoriesInstancename { + + public static void main(String[] args) throws Exception { + syncListInventoriesInstancename(); + } + + public static void syncListInventoriesInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_instancename_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java new file mode 100644 index 000000000000..4a98b8a19b5c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_string_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListInventoriesString { + + public static void main(String[] args) throws Exception { + syncListInventoriesString(); + } + + public static void syncListInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]").toString(); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java new file mode 100644 index 000000000000..dc56c210d372 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReports(); + } + + public static void asyncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentReportsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignmentReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java new file mode 100644 index 000000000000..35b0b6855557 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java @@ -0,0 +1,65 @@ +/* + * 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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReportsPaged(); + } + + public static void asyncListOSPolicyAssignmentReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentReportsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentReportsCallable().call(request); + for (OSPolicyAssignmentReport element : response.getOsPolicyAssignmentReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java new file mode 100644 index 000000000000..c7025b2d306d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReports(); + } + + public static void syncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java new file mode 100644 index 000000000000..dda8e0a7c2aa --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java new file mode 100644 index 000000000000..fad41b557797 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsString(); + } + + public static void syncListOSPolicyAssignmentReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 000000000000..53493bb053b4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java @@ -0,0 +1,56 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisions(); + } + + public static void asyncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentRevisionsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java new file mode 100644 index 000000000000..b60bac6651c1 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java @@ -0,0 +1,64 @@ +/* + * 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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentRevisionsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisionsPaged(); + } + + public static void asyncListOSPolicyAssignmentRevisionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentRevisionsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentRevisionsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 000000000000..8c9a9a7b0c8c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisions(); + } + + public static void syncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java new file mode 100644 index 000000000000..4fb3d1deaace --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsOspolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentRevisionsOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java new file mode 100644 index 000000000000..a30c74b1f83a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsString(); + } + + public static void syncListOSPolicyAssignmentRevisionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java new file mode 100644 index 000000000000..bec84cddceb1 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignments(); + } + + public static void asyncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listOSPolicyAssignmentsPagedCallable().futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java new file mode 100644 index 000000000000..f0cfedb72063 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentsPaged(); + } + + public static void asyncListOSPolicyAssignmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java new file mode 100644 index 000000000000..c91c2aac2591 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java @@ -0,0 +1,49 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_sync] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignments(); + } + + public static void syncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java new file mode 100644 index 000000000000..9e47c4188ba7 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsLocationname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsLocationname(); + } + + public static void syncListOSPolicyAssignmentsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java new file mode 100644 index 000000000000..69a3e35e275c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsString(); + } + + public static void syncListOSPolicyAssignmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java new file mode 100644 index 000000000000..5407771caacd --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java @@ -0,0 +1,56 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class AsyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReports(); + } + + public static void asyncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listVulnerabilityReportsPagedCallable().futureCall(request); + // Do something. + for (VulnerabilityReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java new file mode 100644 index 000000000000..6c21d435a753 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java @@ -0,0 +1,64 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.common.base.Strings; + +public class AsyncListVulnerabilityReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReportsPaged(); + } + + public static void asyncListVulnerabilityReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListVulnerabilityReportsResponse response = + osConfigZonalServiceClient.listVulnerabilityReportsCallable().call(request); + for (VulnerabilityReport element : response.getVulnerabilityReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java new file mode 100644 index 000000000000..3c68ceca0e40 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class SyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReports(); + } + + public static void syncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java new file mode 100644 index 000000000000..d33ed4432c1f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class SyncListVulnerabilityReportsInstancename { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsInstancename(); + } + + public static void syncListVulnerabilityReportsInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java new file mode 100644 index 000000000000..a2418dabfdd9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class SyncListVulnerabilityReportsString { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsString(); + } + + public static void syncListVulnerabilityReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]").toString(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java new file mode 100644 index 000000000000..3e133eca2ad3 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignment(); + } + + public static void asyncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.updateOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java new file mode 100644 index 000000000000..72ddeacf01ca --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignmentLRO(); + } + + public static void asyncUpdateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .updateOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java new file mode 100644 index 000000000000..0ce43a4177db --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignment(); + } + + public static void syncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.updateOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java new file mode 100644 index 000000000000..f577b1626ff9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.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.osconfig.v1.samples; + +// [START +// osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask(); + } + + public static void syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + OSPolicyAssignment response = + osConfigZonalServiceClient + .updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask) + .get(); + } + } +} +// [END +// osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..9152ef9b37bd --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalservicesettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigzonalservicesettings_getospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 000000000000..d66d1429511b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.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.osconfig.v1.stub.samples; + +// [START osconfig_v1_generated_osconfigservicestubsettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1.stub.OsConfigServiceStubSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceStubSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceStubSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceStubSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigservicestubsettings_executepatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..a48d9f0bb4b2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.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.osconfig.v1.stub.samples; + +// [START osconfig_v1_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1.stub.OsConfigZonalServiceStubSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceStubSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceStubSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceStubSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..740d76cabe3d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..52061043a72f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; + +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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..fa7b736a0571 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setendpoint_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java new file mode 100644 index 000000000000..950ce351eaec --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignment(); + } + + public static void asyncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + ApiFuture future = + osConfigZonalServiceClient.createOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java new file mode 100644 index 000000000000..c3a2618991f5 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncCreateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignmentLRO(); + } + + public static void asyncCreateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OperationFuture future = + osConfigZonalServiceClient + .createOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java new file mode 100644 index 000000000000..02b79c0e1691 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignment(); + } + + public static void syncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.createOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java new file mode 100644 index 000000000000..1480ca20a13d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java new file mode 100644 index 000000000000..0aa6db02f5b2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentStringOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentStringOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentStringOspolicyassignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java new file mode 100644 index 000000000000..63629f8c4b36 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignment(); + } + + public static void asyncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.deleteOSPolicyAssignmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java new file mode 100644 index 000000000000..c679b07b26d3 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignmentLRO(); + } + + public static void asyncDeleteOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .deleteOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java new file mode 100644 index 000000000000..195092c9b44a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignment(); + } + + public static void syncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 000000000000..ba0612c9f904 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncDeleteOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncDeleteOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java new file mode 100644 index 000000000000..ac532038021b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncDeleteOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentString(); + } + + public static void syncDeleteOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.java new file mode 100644 index 000000000000..720a618190df --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetInstanceOSPoliciesCompliance { + + public static void main(String[] args) throws Exception { + asyncGetInstanceOSPoliciesCompliance(); + } + + public static void asyncGetInstanceOSPoliciesCompliance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInstanceOSPoliciesComplianceRequest request = + GetInstanceOSPoliciesComplianceRequest.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getInstanceOSPoliciesComplianceCallable().futureCall(request); + // Do something. + InstanceOSPoliciesCompliance response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.java new file mode 100644 index 000000000000..2ff82be0d1e1 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_sync] +import com.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInstanceOSPoliciesCompliance { + + public static void main(String[] args) throws Exception { + syncGetInstanceOSPoliciesCompliance(); + } + + public static void syncGetInstanceOSPoliciesCompliance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInstanceOSPoliciesComplianceRequest request = + GetInstanceOSPoliciesComplianceRequest.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .build(); + InstanceOSPoliciesCompliance response = + osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.java new file mode 100644 index 000000000000..5e6fc84216f1 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_instanceospoliciescompliancename_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename { + + public static void main(String[] args) throws Exception { + syncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename(); + } + + public static void syncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceOSPoliciesComplianceName name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + InstanceOSPoliciesCompliance response = + osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(name); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_instanceospoliciescompliancename_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.java new file mode 100644 index 000000000000..54a435e917a4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInstanceOSPoliciesComplianceString { + + public static void main(String[] args) throws Exception { + syncGetInstanceOSPoliciesComplianceString(); + } + + public static void syncGetInstanceOSPoliciesComplianceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + InstanceOSPoliciesCompliance response = + osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(name); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java new file mode 100644 index 000000000000..ba16ee04eab8 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetInventoryRequest; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetInventory { + + public static void main(String[] args) throws Exception { + asyncGetInventory(); + } + + public static void asyncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getInventoryCallable().futureCall(request); + // Do something. + Inventory response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.java new file mode 100644 index 000000000000..39437914a6ca --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_sync] +import com.google.cloud.osconfig.v1alpha.GetInventoryRequest; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInventory { + + public static void main(String[] args) throws Exception { + syncGetInventory(); + } + + public static void syncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + Inventory response = osConfigZonalServiceClient.getInventory(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java new file mode 100644 index 000000000000..d99d53d4791d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInventoryInventoryname { + + public static void main(String[] args) throws Exception { + syncGetInventoryInventoryname(); + } + + public static void syncGetInventoryInventoryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java new file mode 100644 index 000000000000..c6d43ff81b1d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_string_sync] +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInventoryString { + + public static void main(String[] args) throws Exception { + syncGetInventoryString(); + } + + public static void syncGetInventoryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..6c786812a7fa --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignment(); + } + + public static void asyncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentCallable().futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..e638df3571a4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 000000000000..bdec1ece1cd0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncGetOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java new file mode 100644 index 000000000000..90d3d5d2f68c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentString(); + } + + public static void syncGetOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java new file mode 100644 index 000000000000..b48602f2e7a8 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignmentReport(); + } + + public static void asyncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentReportCallable().futureCall(request); + // Do something. + OSPolicyAssignmentReport response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java new file mode 100644 index 000000000000..a13fe6192016 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReport(); + } + + public static void syncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java new file mode 100644 index 000000000000..4a99188d8169 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportOspolicyassignmentreportname(); + } + + public static void syncGetOSPolicyAssignmentReportOspolicyassignmentreportname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java new file mode 100644 index 000000000000..e135a00d8ef9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportString(); + } + + public static void syncGetOSPolicyAssignmentReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java new file mode 100644 index 000000000000..84ffdda583d4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java @@ -0,0 +1,49 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class AsyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + asyncGetVulnerabilityReport(); + } + + public static void asyncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getVulnerabilityReportCallable().futureCall(request); + // Do something. + VulnerabilityReport response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java new file mode 100644 index 000000000000..d5d4d7592594 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] +import com.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class SyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReport(); + } + + public static void syncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java new file mode 100644 index 000000000000..35cb0ff00c4d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportString { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportString(); + } + + public static void syncGetVulnerabilityReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java new file mode 100644 index 000000000000..bdc61ef6206d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportVulnerabilityreportname { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportVulnerabilityreportname(); + } + + public static void syncGetVulnerabilityReportVulnerabilityreportname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java new file mode 100644 index 000000000000..9782806968f0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java @@ -0,0 +1,57 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListInstanceOSPoliciesCompliances { + + public static void main(String[] args) throws Exception { + asyncListInstanceOSPoliciesCompliances(); + } + + public static void asyncListInstanceOSPoliciesCompliances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInstanceOSPoliciesCompliancesRequest request = + ListInstanceOSPoliciesCompliancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listInstanceOSPoliciesCompliancesPagedCallable() + .futureCall(request); + // Do something. + for (InstanceOSPoliciesCompliance element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java new file mode 100644 index 000000000000..b609b11df8d2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java @@ -0,0 +1,64 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesResponse; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListInstanceOSPoliciesCompliancesPaged { + + public static void main(String[] args) throws Exception { + asyncListInstanceOSPoliciesCompliancesPaged(); + } + + public static void asyncListInstanceOSPoliciesCompliancesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInstanceOSPoliciesCompliancesRequest request = + ListInstanceOSPoliciesCompliancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInstanceOSPoliciesCompliancesResponse response = + osConfigZonalServiceClient.listInstanceOSPoliciesCompliancesCallable().call(request); + for (InstanceOSPoliciesCompliance element : + response.getInstanceOsPoliciesCompliancesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.java new file mode 100644 index 000000000000..04d0f199377d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInstanceOSPoliciesCompliances { + + public static void main(String[] args) throws Exception { + syncListInstanceOSPoliciesCompliances(); + } + + public static void syncListInstanceOSPoliciesCompliances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInstanceOSPoliciesCompliancesRequest request = + ListInstanceOSPoliciesCompliancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (InstanceOSPoliciesCompliance element : + osConfigZonalServiceClient.listInstanceOSPoliciesCompliances(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.java new file mode 100644 index 000000000000..a5df343dc523 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_locationname_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInstanceOSPoliciesCompliancesLocationname { + + public static void main(String[] args) throws Exception { + syncListInstanceOSPoliciesCompliancesLocationname(); + } + + public static void syncListInstanceOSPoliciesCompliancesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (InstanceOSPoliciesCompliance element : + osConfigZonalServiceClient.listInstanceOSPoliciesCompliances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_locationname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.java new file mode 100644 index 000000000000..f96eda9b6575 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInstanceOSPoliciesCompliancesString { + + public static void main(String[] args) throws Exception { + syncListInstanceOSPoliciesCompliancesString(); + } + + public static void syncListInstanceOSPoliciesCompliancesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (InstanceOSPoliciesCompliance element : + osConfigZonalServiceClient.listInstanceOSPoliciesCompliances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java new file mode 100644 index 000000000000..ba4d07f108e2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java @@ -0,0 +1,55 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListInventories { + + public static void main(String[] args) throws Exception { + asyncListInventories(); + } + + public static void asyncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listInventoriesPagedCallable().futureCall(request); + // Do something. + for (Inventory element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java new file mode 100644 index 000000000000..dbb69423914f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java @@ -0,0 +1,63 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.ListInventoriesResponse; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListInventoriesPaged { + + public static void main(String[] args) throws Exception { + asyncListInventoriesPaged(); + } + + public static void asyncListInventoriesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInventoriesResponse response = + osConfigZonalServiceClient.listInventoriesCallable().call(request); + for (Inventory element : response.getInventoriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.java new file mode 100644 index 000000000000..d1f3a353499e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInventories { + + public static void main(String[] args) throws Exception { + syncListInventories(); + } + + public static void syncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Inventory element : osConfigZonalServiceClient.listInventories(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java new file mode 100644 index 000000000000..9740f76a2bcb --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_instancename_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInventoriesInstancename { + + public static void main(String[] args) throws Exception { + syncListInventoriesInstancename(); + } + + public static void syncListInventoriesInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_instancename_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java new file mode 100644 index 000000000000..6eec7290ea7a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInventoriesString { + + public static void main(String[] args) throws Exception { + syncListInventoriesString(); + } + + public static void syncListInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java new file mode 100644 index 000000000000..7cfd749264a4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReports(); + } + + public static void asyncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentReportsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignmentReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java new file mode 100644 index 000000000000..dfd34db62b28 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java @@ -0,0 +1,66 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReportsPaged(); + } + + public static void asyncListOSPolicyAssignmentReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentReportsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentReportsCallable().call(request); + for (OSPolicyAssignmentReport element : response.getOsPolicyAssignmentReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java new file mode 100644 index 000000000000..905902a4c64d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReports(); + } + + public static void syncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java new file mode 100644 index 000000000000..3922f6b59e4d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java new file mode 100644 index 000000000000..05278b799af5 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsString(); + } + + public static void syncListOSPolicyAssignmentReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 000000000000..95579738fea5 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java @@ -0,0 +1,57 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisions(); + } + + public static void asyncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentRevisionsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java new file mode 100644 index 000000000000..f6ebaa720c40 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java @@ -0,0 +1,64 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentRevisionsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisionsPaged(); + } + + public static void asyncListOSPolicyAssignmentRevisionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentRevisionsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentRevisionsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 000000000000..cca72e6db250 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisions(); + } + + public static void syncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java new file mode 100644 index 000000000000..87fa46ef2135 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsOspolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentRevisionsOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java new file mode 100644 index 000000000000..f7cb438397e9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsString(); + } + + public static void syncListOSPolicyAssignmentRevisionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java new file mode 100644 index 000000000000..7266def9b817 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignments(); + } + + public static void asyncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listOSPolicyAssignmentsPagedCallable().futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java new file mode 100644 index 000000000000..938c01732181 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentsPaged(); + } + + public static void asyncListOSPolicyAssignmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java new file mode 100644 index 000000000000..911e05115381 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java @@ -0,0 +1,49 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_sync] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignments(); + } + + public static void syncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java new file mode 100644 index 000000000000..11618fd403fd --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsLocationname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsLocationname(); + } + + public static void syncListOSPolicyAssignmentsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java new file mode 100644 index 000000000000..8e356bc33ba7 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsString(); + } + + public static void syncListOSPolicyAssignmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java new file mode 100644 index 000000000000..c95004017712 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class AsyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReports(); + } + + public static void asyncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listVulnerabilityReportsPagedCallable().futureCall(request); + // Do something. + for (VulnerabilityReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java new file mode 100644 index 000000000000..0d53509d843c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java @@ -0,0 +1,62 @@ +/* + * 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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.common.base.Strings; + +public class AsyncListVulnerabilityReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReportsPaged(); + } + + public static void asyncListVulnerabilityReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListVulnerabilityReportsResponse response = + osConfigZonalServiceClient.listVulnerabilityReportsCallable().call(request); + for (VulnerabilityReport element : response.getVulnerabilityReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java new file mode 100644 index 000000000000..0426d2659c55 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class SyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReports(); + } + + public static void syncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java new file mode 100644 index 000000000000..80562c70fd8e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class SyncListVulnerabilityReportsInstancename { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsInstancename(); + } + + public static void syncListVulnerabilityReportsInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java new file mode 100644 index 000000000000..b5de96ba225e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class SyncListVulnerabilityReportsString { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsString(); + } + + public static void syncListVulnerabilityReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java new file mode 100644 index 000000000000..bd66e5b5cf78 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignment(); + } + + public static void asyncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.updateOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java new file mode 100644 index 000000000000..b910f09314f0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignmentLRO(); + } + + public static void asyncUpdateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .updateOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java new file mode 100644 index 000000000000..bef50cacbb7b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignment(); + } + + public static void syncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.updateOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java new file mode 100644 index 000000000000..d92979e3a957 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.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.osconfig.v1alpha.samples; + +// [START +// osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask(); + } + + public static void syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + OSPolicyAssignment response = + osConfigZonalServiceClient + .updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask) + .get(); + } + } +} +// [END +// osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..8d9a8a6f854d --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalservicesettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalservicesettings_getospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 000000000000..d4de76d312b2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.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.osconfig.v1alpha.stub.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.stub.OsConfigZonalServiceStubSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceStubSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceStubSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceStubSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java new file mode 100644 index 000000000000..bec62b7412f9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + asyncCancelPatchJob(); + } + + public static void asyncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.cancelPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java new file mode 100644 index 000000000000..1e1218fa7484 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + syncCancelPatchJob(); + } + + public static void syncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder().setName("name3373707").build(); + PatchJobs.PatchJob response = osConfigServiceClient.cancelPatchJob(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..e430d0df4960 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..8ecb3b523ef0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; + +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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetEndpoint.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..1de949aa0a7c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_create_setendpoint_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.java new file mode 100644 index 000000000000..5df1cec47e76 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class AsyncCreateGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncCreateGuestPolicy(); + } + + public static void asyncCreateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.CreateGuestPolicyRequest request = + GuestPolicies.CreateGuestPolicyRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setGuestPolicyId("guestPolicyId1234592741") + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.createGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.GuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.java new file mode 100644 index 000000000000..77ee5cb44e3f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncCreateGuestPolicy { + + public static void main(String[] args) throws Exception { + syncCreateGuestPolicy(); + } + + public static void syncCreateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.CreateGuestPolicyRequest request = + GuestPolicies.CreateGuestPolicyRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setGuestPolicyId("guestPolicyId1234592741") + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .build(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.createGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.java new file mode 100644 index 000000000000..62cfb5acfd79 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.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.osconfig.v1beta.samples; + +// [START +// osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_projectnameguestpoliciesguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy { + + public static void main(String[] args) throws Exception { + syncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy(); + } + + public static void syncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.GuestPolicy response = + osConfigServiceClient.createGuestPolicy(parent, guestPolicy); + } + } +} +// [END +// osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_projectnameguestpoliciesguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.java new file mode 100644 index 000000000000..9658580cb738 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.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.osconfig.v1beta.samples; + +// [START +// osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_stringguestpoliciesguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncCreateGuestPolicyStringGuestpoliciesguestpolicy { + + public static void main(String[] args) throws Exception { + syncCreateGuestPolicyStringGuestpoliciesguestpolicy(); + } + + public static void syncCreateGuestPolicyStringGuestpoliciesguestpolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.GuestPolicy response = + osConfigServiceClient.createGuestPolicy(parent, guestPolicy); + } + } +} +// [END +// osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_stringguestpoliciesguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java new file mode 100644 index 000000000000..6f17092214d9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncCreatePatchDeployment(); + } + + public static void asyncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("parent-995424086") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.createPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java new file mode 100644 index 000000000000..ca711368e401 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeployment(); + } + + public static void syncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("parent-995424086") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.java new file mode 100644 index 000000000000..2cd9ccb28619 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncDeleteGuestPolicy(); + } + + public static void asyncDeleteGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.DeleteGuestPolicyRequest request = + GuestPolicies.DeleteGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.deleteGuestPolicyCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.java new file mode 100644 index 000000000000..345c4ccca54b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncDeleteGuestPolicy { + + public static void main(String[] args) throws Exception { + syncDeleteGuestPolicy(); + } + + public static void syncDeleteGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.DeleteGuestPolicyRequest request = + GuestPolicies.DeleteGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + osConfigServiceClient.deleteGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.java new file mode 100644 index 000000000000..42a094d56393 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_guestpolicyname_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncDeleteGuestPolicyGuestpolicyname { + + public static void main(String[] args) throws Exception { + syncDeleteGuestPolicyGuestpolicyname(); + } + + public static void syncDeleteGuestPolicyGuestpolicyname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + osConfigServiceClient.deleteGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_guestpolicyname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.java new file mode 100644 index 000000000000..f86dd5a4197b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_string_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncDeleteGuestPolicyString { + + public static void main(String[] args) throws Exception { + syncDeleteGuestPolicyString(); + } + + public static void syncDeleteGuestPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString(); + osConfigServiceClient.deleteGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java new file mode 100644 index 000000000000..13d597348f69 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.Empty; + +public class AsyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncDeletePatchDeployment(); + } + + public static void asyncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.deletePatchDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java new file mode 100644 index 000000000000..f0182bada9c7 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeployment(); + } + + public static void syncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder().setName("name3373707").build(); + osConfigServiceClient.deletePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java new file mode 100644 index 000000000000..71c0847bf5d2 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java @@ -0,0 +1,53 @@ +/* + * 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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.protobuf.Duration; + +public class AsyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + asyncExecutePatchJob(); + } + + public static void asyncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("parent-995424086") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.executePatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 000000000000..fe3595a88b88 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,49 @@ +/* + * 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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.protobuf.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("parent-995424086") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.executePatchJob(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.java new file mode 100644 index 000000000000..be78c56a9865 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class AsyncGetGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncGetGuestPolicy(); + } + + public static void asyncGetGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.GetGuestPolicyRequest request = + GuestPolicies.GetGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.getGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.GuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.java new file mode 100644 index 000000000000..9ff2e04db597 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncGetGuestPolicy { + + public static void main(String[] args) throws Exception { + syncGetGuestPolicy(); + } + + public static void syncGetGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.GetGuestPolicyRequest request = + GuestPolicies.GetGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.getGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.java new file mode 100644 index 000000000000..8c633ddfce15 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_guestpolicyname_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncGetGuestPolicyGuestpolicyname { + + public static void main(String[] args) throws Exception { + syncGetGuestPolicyGuestpolicyname(); + } + + public static void syncGetGuestPolicyGuestpolicyname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + GuestPolicies.GuestPolicy response = osConfigServiceClient.getGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_guestpolicyname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.java new file mode 100644 index 000000000000..592a7af8b478 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_string_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncGetGuestPolicyString { + + public static void main(String[] args) throws Exception { + syncGetGuestPolicyString(); + } + + public static void syncGetGuestPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.getGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java new file mode 100644 index 000000000000..5410a1772c99 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + asyncGetPatchDeployment(); + } + + public static void asyncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.getPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java new file mode 100644 index 000000000000..b3e4e847b026 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + syncGetPatchDeployment(); + } + + public static void syncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder().setName("name3373707").build(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java new file mode 100644 index 000000000000..9347d9ad6bc6 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncGetPatchJob { + + public static void main(String[] args) throws Exception { + asyncGetPatchJob(); + } + + public static void asyncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.getPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java new file mode 100644 index 000000000000..fa515fa56dd0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncGetPatchJob { + + public static void main(String[] args) throws Exception { + syncGetPatchJob(); + } + + public static void syncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder().setName("name3373707").build(); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.java new file mode 100644 index 000000000000..c5bb356ec2ef --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class AsyncListGuestPolicies { + + public static void main(String[] args) throws Exception { + asyncListGuestPolicies(); + } + + public static void asyncListGuestPolicies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.ListGuestPoliciesRequest request = + GuestPolicies.ListGuestPoliciesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigServiceClient.listGuestPoliciesPagedCallable().futureCall(request); + // Do something. + for (GuestPolicies.GuestPolicy element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java new file mode 100644 index 000000000000..c04ac2ef9d13 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java @@ -0,0 +1,57 @@ +/* + * 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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_paged_async] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListGuestPoliciesPaged { + + public static void main(String[] args) throws Exception { + asyncListGuestPoliciesPaged(); + } + + public static void asyncListGuestPoliciesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.ListGuestPoliciesRequest request = + GuestPolicies.ListGuestPoliciesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + GuestPolicies.ListGuestPoliciesResponse response = + osConfigServiceClient.listGuestPoliciesCallable().call(request); + for (GuestPolicies.GuestPolicy element : response.getGuestPoliciesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.java new file mode 100644 index 000000000000..cf0933511668 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncListGuestPolicies { + + public static void main(String[] args) throws Exception { + syncListGuestPolicies(); + } + + public static void syncListGuestPolicies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.ListGuestPoliciesRequest request = + GuestPolicies.ListGuestPoliciesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (GuestPolicies.GuestPolicy element : + osConfigServiceClient.listGuestPolicies(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.java new file mode 100644 index 000000000000..8e7b830ee472 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_projectname_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncListGuestPoliciesProjectname { + + public static void main(String[] args) throws Exception { + syncListGuestPoliciesProjectname(); + } + + public static void syncListGuestPoliciesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (GuestPolicies.GuestPolicy element : + osConfigServiceClient.listGuestPolicies(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_projectname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.java new file mode 100644 index 000000000000..b80c460ce007 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_string_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncListGuestPoliciesString { + + public static void main(String[] args) throws Exception { + syncListGuestPoliciesString(); + } + + public static void syncListGuestPoliciesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (GuestPolicies.GuestPolicy element : + osConfigServiceClient.listGuestPolicies(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java new file mode 100644 index 000000000000..d2aeeea8885f --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java @@ -0,0 +1,49 @@ +/* + * 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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + asyncListPatchDeployments(); + } + + public static void asyncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchDeploymentsPagedCallable().futureCall(request); + // Do something. + for (PatchDeployments.PatchDeployment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java new file mode 100644 index 000000000000..3d2dd00dd063 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java @@ -0,0 +1,56 @@ +/* + * 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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_paged_async] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.common.base.Strings; + +public class AsyncListPatchDeploymentsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchDeploymentsPaged(); + } + + public static void asyncListPatchDeploymentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + PatchDeployments.ListPatchDeploymentsResponse response = + osConfigServiceClient.listPatchDeploymentsCallable().call(request); + for (PatchDeployments.PatchDeployment element : response.getPatchDeploymentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java new file mode 100644 index 000000000000..80c877200e18 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + syncListPatchDeployments(); + } + + public static void syncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java new file mode 100644 index 000000000000..097fda43ac1b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetails(); + } + + public static void asyncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobInstanceDetailsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJobInstanceDetails element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java new file mode 100644 index 000000000000..e91249ef751a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.common.base.Strings; + +public class AsyncListPatchJobInstanceDetailsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetailsPaged(); + } + + public static void asyncListPatchJobInstanceDetailsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobInstanceDetailsResponse response = + osConfigServiceClient.listPatchJobInstanceDetailsCallable().call(request); + for (PatchJobs.PatchJobInstanceDetails element : + response.getPatchJobInstanceDetailsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java new file mode 100644 index 000000000000..64c770453357 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetails(); + } + + public static void syncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java new file mode 100644 index 000000000000..4a743ed18e1c --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncListPatchJobInstanceDetailsString { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetailsString(); + } + + public static void syncListPatchJobInstanceDetailsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = "parent-995424086"; + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java new file mode 100644 index 000000000000..36e72be9e213 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncListPatchJobs { + + public static void main(String[] args) throws Exception { + asyncListPatchJobs(); + } + + public static void asyncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJob element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java new file mode 100644 index 000000000000..b2309df322b1 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java @@ -0,0 +1,57 @@ +/* + * 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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_paged_async] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.common.base.Strings; + +public class AsyncListPatchJobsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobsPaged(); + } + + public static void asyncListPatchJobsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobsResponse response = + osConfigServiceClient.listPatchJobsCallable().call(request); + for (PatchJobs.PatchJob element : response.getPatchJobsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_paged_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java new file mode 100644 index 000000000000..79d6d0c66cc7 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncListPatchJobs { + + public static void main(String[] args) throws Exception { + syncListPatchJobs(); + } + + public static void syncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.java new file mode 100644 index 000000000000..5b0a5247f98a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class AsyncLookupEffectiveGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncLookupEffectiveGuestPolicy(); + } + + public static void asyncLookupEffectiveGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("instance555127957") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + ApiFuture future = + osConfigServiceClient.lookupEffectiveGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.EffectiveGuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.java new file mode 100644 index 000000000000..927792e3716a --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncLookupEffectiveGuestPolicy { + + public static void main(String[] args) throws Exception { + syncLookupEffectiveGuestPolicy(); + } + + public static void syncLookupEffectiveGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("instance555127957") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + GuestPolicies.EffectiveGuestPolicy response = + osConfigServiceClient.lookupEffectiveGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java new file mode 100644 index 000000000000..7e91a7618de9 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncPausePatchDeployment(); + } + + public static void asyncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.pausePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java new file mode 100644 index 000000000000..16c7598e3f31 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + syncPausePatchDeployment(); + } + + public static void syncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.pausePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java new file mode 100644 index 000000000000..bf757165ee7e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.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.osconfig.v1beta.samples; + +// [START +// osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncPausePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentPatchdeploymentname(); + } + + public static void syncPausePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END +// osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java new file mode 100644 index 000000000000..71c65f5c41df --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncPausePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentString(); + } + + public static void syncPausePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java new file mode 100644 index 000000000000..fc64908dfcba --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncResumePatchDeployment(); + } + + public static void asyncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.resumePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java new file mode 100644 index 000000000000..f9bdeb8aec4b --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + syncResumePatchDeployment(); + } + + public static void syncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.resumePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java new file mode 100644 index 000000000000..ffe955464a51 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.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.osconfig.v1beta.samples; + +// [START +// osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncResumePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentPatchdeploymentname(); + } + + public static void syncResumePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END +// osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java new file mode 100644 index 000000000000..6200b7f7932e --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncResumePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentString(); + } + + public static void syncResumePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_string_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.java new file mode 100644 index 000000000000..9fe7573aaaeb --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncUpdateGuestPolicy(); + } + + public static void asyncUpdateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.UpdateGuestPolicyRequest request = + GuestPolicies.UpdateGuestPolicyRequest.newBuilder() + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.updateGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.GuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.java new file mode 100644 index 000000000000..14f5d73e1876 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateGuestPolicy { + + public static void main(String[] args) throws Exception { + syncUpdateGuestPolicy(); + } + + public static void syncUpdateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.UpdateGuestPolicyRequest request = + GuestPolicies.UpdateGuestPolicyRequest.newBuilder() + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.updateGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.java new file mode 100644 index 000000000000..3fb6a96041c0 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.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.osconfig.v1beta.samples; + +// [START +// osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_guestpoliciesguestpolicyfieldmask_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask(); + } + + public static void syncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + GuestPolicies.GuestPolicy response = + osConfigServiceClient.updateGuestPolicy(guestPolicy, updateMask); + } + } +} +// [END +// osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_guestpoliciesguestpolicyfieldmask_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java new file mode 100644 index 000000000000..b81c1ea1b379 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class AsyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncUpdatePatchDeployment(); + } + + public static void asyncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.updatePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_async] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java new file mode 100644 index 000000000000..1661b7dc1e47 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeployment(); + } + + public static void syncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java new file mode 100644 index 000000000000..1645e5c80cc4 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.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.osconfig.v1beta.samples; + +// [START +// osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask(); + } + + public static void syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(patchDeployment, updateMask); + } + } +} +// [END +// osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 000000000000..2916e08ede39 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigservicesettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1beta_generated_osconfigservicesettings_executepatchjob_sync] diff --git a/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 000000000000..2cf0e889e373 --- /dev/null +++ b/java-os-config/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.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.osconfig.v1beta.stub.samples; + +// [START osconfig_v1beta_generated_osconfigservicestubsettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1beta.stub.OsConfigServiceStubSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceStubSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceStubSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceStubSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1beta_generated_osconfigservicestubsettings_executepatchjob_sync]