From d732072e04c7aa4068395d905a711a5bbb7d8282 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 17:49:56 -0400 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#794) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Enable REST transport for most of Java and Go clients 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 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: fix deps Co-authored-by: Owl Bot Co-authored-by: Neenu1995 --- .../google-cloud-resourcemanager/pom.xml | 16 + .../resourcemanager/v3/FoldersClient.java | 37 +- .../resourcemanager/v3/FoldersSettings.java | 23 +- .../v3/OrganizationsClient.java | 14 + .../v3/OrganizationsSettings.java | 23 +- .../resourcemanager/v3/ProjectsClient.java | 37 +- .../resourcemanager/v3/ProjectsSettings.java | 23 +- .../resourcemanager/v3/TagBindingsClient.java | 37 +- .../v3/TagBindingsSettings.java | 23 +- .../resourcemanager/v3/TagKeysClient.java | 37 +- .../resourcemanager/v3/TagKeysSettings.java | 23 +- .../resourcemanager/v3/TagValuesClient.java | 37 +- .../resourcemanager/v3/TagValuesSettings.java | 23 +- .../resourcemanager/v3/stub/FoldersStub.java | 6 +- .../v3/stub/FoldersStubSettings.java | 52 +- .../stub/HttpJsonFoldersCallableFactory.java | 105 ++ .../v3/stub/HttpJsonFoldersStub.java | 846 ++++++++++++ .../HttpJsonOrganizationsCallableFactory.java | 105 ++ .../v3/stub/HttpJsonOrganizationsStub.java | 428 ++++++ .../stub/HttpJsonProjectsCallableFactory.java | 105 ++ .../v3/stub/HttpJsonProjectsStub.java | 848 ++++++++++++ .../HttpJsonTagBindingsCallableFactory.java | 105 ++ .../v3/stub/HttpJsonTagBindingsStub.java | 365 +++++ .../stub/HttpJsonTagKeysCallableFactory.java | 105 ++ .../v3/stub/HttpJsonTagKeysStub.java | 644 +++++++++ .../HttpJsonTagValuesCallableFactory.java | 105 ++ .../v3/stub/HttpJsonTagValuesStub.java | 651 +++++++++ .../v3/stub/OrganizationsStubSettings.java | 53 +- .../resourcemanager/v3/stub/ProjectsStub.java | 6 +- .../v3/stub/ProjectsStubSettings.java | 52 +- .../v3/stub/TagBindingsStub.java | 6 +- .../v3/stub/TagBindingsStubSettings.java | 53 +- .../resourcemanager/v3/stub/TagKeysStub.java | 6 +- .../v3/stub/TagKeysStubSettings.java | 52 +- .../v3/stub/TagValuesStub.java | 6 +- .../v3/stub/TagValuesStubSettings.java | 52 +- .../v3/FoldersClientHttpJsonTest.java | 1197 ++++++++++++++++ .../v3/OrganizationsClientHttpJsonTest.java | 509 +++++++ .../v3/ProjectsClientHttpJsonTest.java | 1226 +++++++++++++++++ .../v3/TagBindingsClientHttpJsonTest.java | 323 +++++ .../v3/TagKeysClientHttpJsonTest.java | 816 +++++++++++ .../v3/TagValuesClientHttpJsonTest.java | 816 +++++++++++ .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../createfolder/AsyncCreateFolder.java | 44 + .../createfolder/AsyncCreateFolderLRO.java | 45 + .../createfolder/SyncCreateFolder.java | 40 + .../createfolder/SyncCreateFolderFolder.java | 38 + .../deletefolder/AsyncDeleteFolder.java | 44 + .../deletefolder/AsyncDeleteFolderLRO.java | 46 + .../deletefolder/SyncDeleteFolder.java | 41 + .../SyncDeleteFolderFoldername.java | 39 + .../deletefolder/SyncDeleteFolderString.java | 39 + .../getfolder/AsyncGetFolder.java | 44 + .../getfolder/SyncGetFolder.java | 41 + .../getfolder/SyncGetFolderFoldername.java | 39 + .../getfolder/SyncGetFolderString.java | 39 + .../getiampolicy/AsyncGetIamPolicy.java | 48 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../SyncGetIamPolicyResourcename.java | 40 + .../getiampolicy/SyncGetIamPolicyString.java | 39 + .../listfolders/AsyncListFolders.java | 51 + .../listfolders/AsyncListFoldersPaged.java | 59 + .../listfolders/SyncListFolders.java | 48 + .../SyncListFoldersResourcename.java | 42 + .../listfolders/SyncListFoldersString.java | 41 + .../movefolder/AsyncMoveFolder.java | 47 + .../movefolder/AsyncMoveFolderLRO.java | 49 + .../movefolder/SyncMoveFolder.java | 44 + .../SyncMoveFolderFoldernameResourcename.java | 41 + .../SyncMoveFolderFoldernameString.java | 40 + .../SyncMoveFolderStringResourcename.java | 41 + .../SyncMoveFolderStringString.java | 40 + .../searchfolders/AsyncSearchFolders.java | 49 + .../AsyncSearchFoldersPaged.java | 57 + .../searchfolders/SyncSearchFolders.java | 46 + .../SyncSearchFoldersString.java | 40 + .../setiampolicy/AsyncSetIamPolicy.java | 49 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../SyncSetIamPolicyResourcenamePolicy.java | 41 + .../SyncSetIamPolicyStringPolicy.java | 40 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + ...tIamPermissionsResourcenameListstring.java | 43 + ...yncTestIamPermissionsStringListstring.java | 42 + .../undeletefolder/AsyncUndeleteFolder.java | 44 + .../AsyncUndeleteFolderLRO.java | 46 + .../undeletefolder/SyncUndeleteFolder.java | 41 + .../SyncUndeleteFolderFoldername.java | 39 + .../SyncUndeleteFolderString.java | 39 + .../updatefolder/AsyncUpdateFolder.java | 48 + .../updatefolder/AsyncUpdateFolderLRO.java | 49 + .../updatefolder/SyncUpdateFolder.java | 44 + .../SyncUpdateFolderFolderFieldmask.java | 40 + .../getfolder/SyncGetFolder.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../getiampolicy/AsyncGetIamPolicy.java | 48 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../SyncGetIamPolicyResourcename.java | 40 + .../getiampolicy/SyncGetIamPolicyString.java | 39 + .../getorganization/AsyncGetOrganization.java | 47 + .../getorganization/SyncGetOrganization.java | 43 + .../SyncGetOrganizationOrganizationname.java | 39 + .../SyncGetOrganizationString.java | 39 + .../AsyncSearchOrganizations.java | 50 + .../AsyncSearchOrganizationsPaged.java | 58 + .../SyncSearchOrganizations.java | 46 + .../SyncSearchOrganizationsString.java | 40 + .../setiampolicy/AsyncSetIamPolicy.java | 49 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../SyncSetIamPolicyResourcename.java | 40 + .../setiampolicy/SyncSetIamPolicyString.java | 39 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + ...tIamPermissionsResourcenameListstring.java | 46 + ...yncTestIamPermissionsStringListstring.java | 43 + .../getorganization/SyncGetOrganization.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createproject/AsyncCreateProject.java | 44 + .../createproject/AsyncCreateProjectLRO.java | 45 + .../createproject/SyncCreateProject.java | 40 + .../SyncCreateProjectProject.java | 38 + .../deleteproject/AsyncDeleteProject.java | 44 + .../deleteproject/AsyncDeleteProjectLRO.java | 46 + .../deleteproject/SyncDeleteProject.java | 41 + .../SyncDeleteProjectProjectname.java | 39 + .../SyncDeleteProjectString.java | 39 + .../getiampolicy/AsyncGetIamPolicy.java | 48 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../SyncGetIamPolicyResourcename.java | 40 + .../getiampolicy/SyncGetIamPolicyString.java | 39 + .../getproject/AsyncGetProject.java | 44 + .../getproject/SyncGetProject.java | 41 + .../getproject/SyncGetProjectProjectname.java | 39 + .../getproject/SyncGetProjectString.java | 39 + .../listprojects/AsyncListProjects.java | 51 + .../listprojects/AsyncListProjectsPaged.java | 59 + .../listprojects/SyncListProjects.java | 48 + .../SyncListProjectsResourcename.java | 42 + .../listprojects/SyncListProjectsString.java | 41 + .../moveproject/AsyncMoveProject.java | 47 + .../moveproject/AsyncMoveProjectLRO.java | 49 + .../moveproject/SyncMoveProject.java | 44 + ...yncMoveProjectProjectnameResourcename.java | 41 + .../SyncMoveProjectProjectnameString.java | 41 + .../SyncMoveProjectStringResourcename.java | 41 + .../SyncMoveProjectStringString.java | 41 + .../searchprojects/AsyncSearchProjects.java | 49 + .../AsyncSearchProjectsPaged.java | 57 + .../searchprojects/SyncSearchProjects.java | 46 + .../SyncSearchProjectsString.java | 40 + .../setiampolicy/AsyncSetIamPolicy.java | 49 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../SyncSetIamPolicyResourcenamePolicy.java | 41 + .../SyncSetIamPolicyStringPolicy.java | 40 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + ...tIamPermissionsResourcenameListstring.java | 45 + ...yncTestIamPermissionsStringListstring.java | 43 + .../undeleteproject/AsyncUndeleteProject.java | 46 + .../AsyncUndeleteProjectLRO.java | 48 + .../undeleteproject/SyncUndeleteProject.java | 43 + .../SyncUndeleteProjectProjectname.java | 39 + .../SyncUndeleteProjectString.java | 39 + .../updateproject/AsyncUpdateProject.java | 48 + .../updateproject/AsyncUpdateProjectLRO.java | 49 + .../updateproject/SyncUpdateProject.java | 44 + .../SyncUpdateProjectProjectFieldmask.java | 40 + .../getproject/SyncGetProject.java | 45 + .../getfolder/SyncGetFolder.java | 45 + .../getorganization/SyncGetOrganization.java | 46 + .../getproject/SyncGetProject.java | 45 + .../listtagbindings/SyncListTagBindings.java | 46 + .../gettagkey/SyncGetTagKey.java | 45 + .../gettagvalue/SyncGetTagValue.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateTagBinding.java | 48 + .../AsyncCreateTagBindingLRO.java | 48 + .../SyncCreateTagBinding.java | 43 + .../SyncCreateTagBindingTagbinding.java | 38 + .../AsyncDeleteTagBinding.java | 47 + .../AsyncDeleteTagBindingLRO.java | 48 + .../SyncDeleteTagBinding.java | 42 + .../SyncDeleteTagBindingString.java | 38 + .../SyncDeleteTagBindingTagbindingname.java | 38 + .../listtagbindings/AsyncListTagBindings.java | 51 + .../AsyncListTagBindingsPaged.java | 59 + .../listtagbindings/SyncListTagBindings.java | 47 + .../SyncListTagBindingsResourcename.java | 42 + .../SyncListTagBindingsString.java | 41 + .../listtagbindings/SyncListTagBindings.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 37 + .../createtagkey/AsyncCreateTagKey.java | 47 + .../createtagkey/AsyncCreateTagKeyLRO.java | 48 + .../createtagkey/SyncCreateTagKey.java | 43 + .../createtagkey/SyncCreateTagKeyTagkey.java | 38 + .../deletetagkey/AsyncDeleteTagKey.java | 48 + .../deletetagkey/AsyncDeleteTagKeyLRO.java | 50 + .../deletetagkey/SyncDeleteTagKey.java | 45 + .../deletetagkey/SyncDeleteTagKeyString.java | 39 + .../SyncDeleteTagKeyTagkeyname.java | 39 + .../getiampolicy/AsyncGetIamPolicy.java | 48 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../SyncGetIamPolicyResourcename.java | 40 + .../getiampolicy/SyncGetIamPolicyString.java | 39 + .../gettagkey/AsyncGetTagKey.java | 44 + .../gettagkey/SyncGetTagKey.java | 41 + .../gettagkey/SyncGetTagKeyString.java | 39 + .../gettagkey/SyncGetTagKeyTagkeyname.java | 39 + .../listtagkeys/AsyncListTagKeys.java | 50 + .../listtagkeys/AsyncListTagKeysPaged.java | 58 + .../listtagkeys/SyncListTagKeys.java | 47 + .../SyncListTagKeysResourcename.java | 42 + .../listtagkeys/SyncListTagKeysString.java | 41 + .../setiampolicy/AsyncSetIamPolicy.java | 49 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../SyncSetIamPolicyResourcenamePolicy.java | 41 + .../SyncSetIamPolicyStringPolicy.java | 40 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + ...tIamPermissionsResourcenameListstring.java | 43 + ...yncTestIamPermissionsStringListstring.java | 42 + .../updatetagkey/AsyncUpdateTagKey.java | 49 + .../updatetagkey/AsyncUpdateTagKeyLRO.java | 50 + .../updatetagkey/SyncUpdateTagKey.java | 45 + .../SyncUpdateTagKeyTagkeyFieldmask.java | 40 + .../gettagkey/SyncGetTagKey.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createtagvalue/AsyncCreateTagValue.java | 47 + .../AsyncCreateTagValueLRO.java | 48 + .../createtagvalue/SyncCreateTagValue.java | 43 + .../SyncCreateTagValueTagvalue.java | 38 + .../deletetagvalue/AsyncDeleteTagValue.java | 48 + .../AsyncDeleteTagValueLRO.java | 50 + .../deletetagvalue/SyncDeleteTagValue.java | 45 + .../SyncDeleteTagValueString.java | 39 + .../SyncDeleteTagValueTagvaluename.java | 39 + .../getiampolicy/AsyncGetIamPolicy.java | 48 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../SyncGetIamPolicyResourcename.java | 40 + .../getiampolicy/SyncGetIamPolicyString.java | 39 + .../gettagvalue/AsyncGetTagValue.java | 46 + .../gettagvalue/SyncGetTagValue.java | 43 + .../gettagvalue/SyncGetTagValueString.java | 39 + .../SyncGetTagValueTagvaluename.java | 39 + .../listtagvalues/AsyncListTagValues.java | 50 + .../AsyncListTagValuesPaged.java | 58 + .../listtagvalues/SyncListTagValues.java | 47 + .../SyncListTagValuesResourcename.java | 42 + .../SyncListTagValuesString.java | 41 + .../setiampolicy/AsyncSetIamPolicy.java | 49 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../SyncSetIamPolicyResourcenamePolicy.java | 41 + .../SyncSetIamPolicyStringPolicy.java | 40 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + ...tIamPermissionsResourcenameListstring.java | 45 + ...yncTestIamPermissionsStringListstring.java | 43 + .../updatetagvalue/AsyncUpdateTagValue.java | 49 + .../AsyncUpdateTagValueLRO.java | 50 + .../updatetagvalue/SyncUpdateTagValue.java | 45 + .../SyncUpdateTagValueTagvalueFieldmask.java | 40 + .../gettagvalue/SyncGetTagValue.java | 45 + 274 files changed, 20129 insertions(+), 60 deletions(-) create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersCallableFactory.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersStub.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsCallableFactory.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsStub.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsCallableFactory.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsStub.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsCallableFactory.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsStub.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysCallableFactory.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysStub.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesCallableFactory.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesStub.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/FoldersClientHttpJsonTest.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/OrganizationsClientHttpJsonTest.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/ProjectsClientHttpJsonTest.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagBindingsClientHttpJsonTest.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagKeysClientHttpJsonTest.java create mode 100644 java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagValuesClientHttpJsonTest.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetEndpoint.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolderLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolderFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolderLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderFoldername.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/AsyncGetFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderFoldername.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFolders.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFoldersPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFolders.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolderLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFolders.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFoldersPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFolders.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFoldersString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyStringPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsStringListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolderLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderFoldername.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolderLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolderFolderFieldmask.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/folderssettings/getfolder/SyncGetFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/AsyncGetOrganization.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganization.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationOrganizationname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizations.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizationsPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizations.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizationsString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsStringListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationssettings/getorganization/SyncGetOrganization.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProjectLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProjectProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProjectLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectProjectname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/AsyncGetProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectProjectname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjects.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjectsPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjects.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProjectLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjects.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjectsPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjects.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjectsString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyStringPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsStringListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProjectLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectProjectname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProjectLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProjectProjectFieldmask.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectssettings/getproject/SyncGetProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/foldersstubsettings/getfolder/SyncGetFolder.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/organizationsstubsettings/getorganization/SyncGetOrganization.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/projectsstubsettings/getproject/SyncGetProject.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagbindingsstubsettings/listtagbindings/SyncListTagBindings.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagkeysstubsettings/gettagkey/SyncGetTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagvaluesstubsettings/gettagvalue/SyncGetTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetEndpoint.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBinding.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBindingLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBinding.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBindingTagbinding.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBinding.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBindingLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBinding.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingTagbindingname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindings.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindingsPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindings.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingssettings/listtagbindings/SyncListTagBindings.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetEndpoint.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKeyLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKeyTagkey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKeyLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyTagkeyname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/AsyncGetTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyTagkeyname.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeys.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeysPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeys.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyStringPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsStringListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKeyLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKeyTagkeyFieldmask.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeyssettings/gettagkey/SyncGetTagKey.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetEndpoint.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValueLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValueTagvalue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValueLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueTagvaluename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/AsyncGetTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueTagvaluename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValues.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValuesPaged.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValues.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesResourcename.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesString.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyStringPolicy.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsStringListstring.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValueLRO.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValue.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValueTagvalueFieldmask.java create mode 100644 java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluessettings/gettagvalue/SyncGetTagValue.java diff --git a/java-resourcemanager/google-cloud-resourcemanager/pom.xml b/java-resourcemanager/google-cloud-resourcemanager/pom.xml index 04f0b4511ddf..b1ef364716ba 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/pom.xml +++ b/java-resourcemanager/google-cloud-resourcemanager/pom.xml @@ -142,6 +142,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + com.google.api gax @@ -188,12 +192,24 @@ grpc-google-cloud-resourcemanager-v3 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersClient.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersClient.java index d089d7ee6cdd..90c29b241fe6 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersClient.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersClient.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; @@ -36,7 +37,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.FieldMask; import java.io.IOException; import java.util.List; @@ -107,13 +107,28 @@ * FoldersClient foldersClient = FoldersClient.create(foldersSettings); * } * + *

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.
+ * FoldersSettings foldersSettings =
+ *     FoldersSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             FoldersSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * FoldersClient foldersClient = FoldersClient.create(foldersSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class FoldersClient implements BackgroundResource { private final FoldersSettings settings; private final FoldersStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of FoldersClient with default settings. */ public static final FoldersClient create() throws IOException { @@ -143,13 +158,17 @@ public static final FoldersClient create(FoldersStub stub) { protected FoldersClient(FoldersSettings settings) throws IOException { this.settings = settings; this.stub = ((FoldersStubSettings) 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 FoldersClient(FoldersStub 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 FoldersSettings getSettings() { @@ -164,10 +183,18 @@ public FoldersStub 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. /** * Retrieves a folder identified by the supplied resource name. Valid folder resource names have diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersSettings.java index 0f07a1b86640..29ae9503c876 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersSettings.java @@ -24,6 +24,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; @@ -191,11 +192,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return FoldersStubSettings.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 FoldersStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FoldersStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return FoldersStubSettings.defaultTransportChannelProvider(); } @@ -205,11 +213,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return FoldersStubSettings.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); @@ -247,6 +261,11 @@ private static Builder createDefault() { return new Builder(FoldersStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(FoldersStubSettings.newHttpJsonBuilder()); + } + public FoldersStubSettings.Builder getStubSettingsBuilder() { return ((FoldersStubSettings.Builder) getStubSettings()); } diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsClient.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsClient.java index 846c37f9cf76..81f1939ef2f8 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsClient.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsClient.java @@ -102,6 +102,20 @@ * OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings); * } * + *

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.
+ * OrganizationsSettings organizationsSettings =
+ *     OrganizationsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OrganizationsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsSettings.java index 223cb7e97283..661eeb0eca36 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsSettings.java @@ -23,6 +23,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; @@ -129,11 +130,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OrganizationsStubSettings.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 OrganizationsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OrganizationsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OrganizationsStubSettings.defaultTransportChannelProvider(); } @@ -143,11 +151,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OrganizationsStubSettings.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); @@ -185,6 +199,11 @@ private static Builder createDefault() { return new Builder(OrganizationsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OrganizationsStubSettings.newHttpJsonBuilder()); + } + public OrganizationsStubSettings.Builder getStubSettingsBuilder() { return ((OrganizationsStubSettings.Builder) getStubSettings()); } diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsClient.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsClient.java index 745701e83bf2..d69c6779daaa 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsClient.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsClient.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; @@ -36,7 +37,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.FieldMask; import java.io.IOException; import java.util.List; @@ -107,13 +107,28 @@ * ProjectsClient projectsClient = ProjectsClient.create(projectsSettings); * } * + *

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.
+ * ProjectsSettings projectsSettings =
+ *     ProjectsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ProjectsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ProjectsClient implements BackgroundResource { private final ProjectsSettings settings; private final ProjectsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ProjectsClient with default settings. */ public static final ProjectsClient create() throws IOException { @@ -143,13 +158,17 @@ public static final ProjectsClient create(ProjectsStub stub) { protected ProjectsClient(ProjectsSettings settings) throws IOException { this.settings = settings; this.stub = ((ProjectsStubSettings) 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 ProjectsClient(ProjectsStub 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 ProjectsSettings getSettings() { @@ -164,10 +183,18 @@ public ProjectsStub 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. /** * Retrieves the project identified by the specified `name` (for example, diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsSettings.java index e66d77ef2ccd..962721d38987 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsSettings.java @@ -24,6 +24,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; @@ -192,11 +193,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ProjectsStubSettings.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 ProjectsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ProjectsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ProjectsStubSettings.defaultTransportChannelProvider(); } @@ -206,11 +214,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ProjectsStubSettings.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); @@ -248,6 +262,11 @@ private static Builder createDefault() { return new Builder(ProjectsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ProjectsStubSettings.newHttpJsonBuilder()); + } + public ProjectsStubSettings.Builder getStubSettingsBuilder() { return ((ProjectsStubSettings.Builder) getStubSettings()); } diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsClient.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsClient.java index 7f6826ff8fb7..6ba9c78ff340 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsClient.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsClient.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; @@ -31,7 +32,6 @@ import com.google.cloud.resourcemanager.v3.stub.TagBindingsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -105,13 +105,28 @@ * TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings); * } * + *

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.
+ * TagBindingsSettings tagBindingsSettings =
+ *     TagBindingsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             TagBindingsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class TagBindingsClient implements BackgroundResource { private final TagBindingsSettings settings; private final TagBindingsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of TagBindingsClient with default settings. */ public static final TagBindingsClient create() throws IOException { @@ -142,13 +157,17 @@ public static final TagBindingsClient create(TagBindingsStub stub) { protected TagBindingsClient(TagBindingsSettings settings) throws IOException { this.settings = settings; this.stub = ((TagBindingsStubSettings) 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 TagBindingsClient(TagBindingsStub 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 TagBindingsSettings getSettings() { @@ -163,10 +182,18 @@ public TagBindingsStub 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. /** * Lists the TagBindings for the given cloud resource, as specified with `parent`. diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsSettings.java index 8b5401c0c67e..08dceb6f0539 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagBindingsSettings.java @@ -23,6 +23,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; @@ -127,11 +128,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return TagBindingsStubSettings.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 TagBindingsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return TagBindingsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return TagBindingsStubSettings.defaultTransportChannelProvider(); } @@ -141,11 +149,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return TagBindingsStubSettings.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); @@ -183,6 +197,11 @@ private static Builder createDefault() { return new Builder(TagBindingsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(TagBindingsStubSettings.newHttpJsonBuilder()); + } + public TagBindingsStubSettings.Builder getStubSettingsBuilder() { return ((TagBindingsStubSettings.Builder) getStubSettings()); } diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysClient.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysClient.java index 6eb120ad8882..0365b0715d48 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysClient.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysClient.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; @@ -36,7 +37,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.FieldMask; import java.io.IOException; import java.util.List; @@ -106,13 +106,28 @@ * TagKeysClient tagKeysClient = TagKeysClient.create(tagKeysSettings); * } * + *

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.
+ * TagKeysSettings tagKeysSettings =
+ *     TagKeysSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             TagKeysSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * TagKeysClient tagKeysClient = TagKeysClient.create(tagKeysSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class TagKeysClient implements BackgroundResource { private final TagKeysSettings settings; private final TagKeysStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of TagKeysClient with default settings. */ public static final TagKeysClient create() throws IOException { @@ -142,13 +157,17 @@ public static final TagKeysClient create(TagKeysStub stub) { protected TagKeysClient(TagKeysSettings settings) throws IOException { this.settings = settings; this.stub = ((TagKeysStubSettings) 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 TagKeysClient(TagKeysStub 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 TagKeysSettings getSettings() { @@ -163,10 +182,18 @@ public TagKeysStub 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. /** * Lists all TagKeys for a parent resource. diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysSettings.java index 889ca7fb3788..5f234572e779 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagKeysSettings.java @@ -23,6 +23,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; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return TagKeysStubSettings.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 TagKeysStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return TagKeysStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return TagKeysStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return TagKeysStubSettings.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); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(TagKeysStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(TagKeysStubSettings.newHttpJsonBuilder()); + } + public TagKeysStubSettings.Builder getStubSettingsBuilder() { return ((TagKeysStubSettings.Builder) getStubSettings()); } diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesClient.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesClient.java index 6d2b148fd9a1..838973a26c00 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesClient.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesClient.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; @@ -36,7 +37,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.FieldMask; import java.io.IOException; import java.util.List; @@ -107,13 +107,28 @@ * TagValuesClient tagValuesClient = TagValuesClient.create(tagValuesSettings); * } * + *

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.
+ * TagValuesSettings tagValuesSettings =
+ *     TagValuesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             TagValuesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * TagValuesClient tagValuesClient = TagValuesClient.create(tagValuesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class TagValuesClient implements BackgroundResource { private final TagValuesSettings settings; private final TagValuesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of TagValuesClient with default settings. */ public static final TagValuesClient create() throws IOException { @@ -143,13 +158,17 @@ public static final TagValuesClient create(TagValuesStub stub) { protected TagValuesClient(TagValuesSettings settings) throws IOException { this.settings = settings; this.stub = ((TagValuesStubSettings) 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 TagValuesClient(TagValuesStub 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 TagValuesSettings getSettings() { @@ -164,10 +183,18 @@ public TagValuesStub 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. /** * Lists all TagValues for a specific TagKey. diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesSettings.java index cf6ded2e741b..0ee4181776e6 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/TagValuesSettings.java @@ -23,6 +23,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; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return TagValuesStubSettings.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 TagValuesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return TagValuesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return TagValuesStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return TagValuesStubSettings.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); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(TagValuesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(TagValuesStubSettings.newHttpJsonBuilder()); + } + public TagValuesStubSettings.Builder getStubSettingsBuilder() { return ((TagValuesStubSettings.Builder) getStubSettings()); } diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStub.java index 34b97b29ef48..979b6e5b81a1 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStub.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStub.java @@ -57,7 +57,11 @@ public abstract class FoldersStub 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 UnaryCallable getFolderCallable() { diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStubSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStubSettings.java index a9feea57b75c..55a0531db10e 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStubSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/FoldersStubSettings.java @@ -29,6 +29,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; @@ -345,6 +348,11 @@ public FoldersStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFoldersStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFoldersStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -377,29 +385,54 @@ 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(FoldersStubSettings.class)) .setTransportToken( 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(FoldersStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FoldersStubSettings.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); @@ -594,6 +627,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 .getFolderSettings() diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersCallableFactory.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersCallableFactory.java new file mode 100644 index 000000000000..780107a0d369 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersCallableFactory.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.resourcemanager.v3.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 Folders service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFoldersCallableFactory + 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersStub.java new file mode 100644 index 000000000000..7180585d5c2b --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonFoldersStub.java @@ -0,0 +1,846 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.stub; + +import static com.google.cloud.resourcemanager.v3.FoldersClient.ListFoldersPagedResponse; +import static com.google.cloud.resourcemanager.v3.FoldersClient.SearchFoldersPagedResponse; + +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.resourcemanager.v3.CreateFolderMetadata; +import com.google.cloud.resourcemanager.v3.CreateFolderRequest; +import com.google.cloud.resourcemanager.v3.DeleteFolderMetadata; +import com.google.cloud.resourcemanager.v3.DeleteFolderRequest; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.GetFolderRequest; +import com.google.cloud.resourcemanager.v3.ListFoldersRequest; +import com.google.cloud.resourcemanager.v3.ListFoldersResponse; +import com.google.cloud.resourcemanager.v3.MoveFolderMetadata; +import com.google.cloud.resourcemanager.v3.MoveFolderRequest; +import com.google.cloud.resourcemanager.v3.SearchFoldersRequest; +import com.google.cloud.resourcemanager.v3.SearchFoldersResponse; +import com.google.cloud.resourcemanager.v3.UndeleteFolderMetadata; +import com.google.cloud.resourcemanager.v3.UndeleteFolderRequest; +import com.google.cloud.resourcemanager.v3.UpdateFolderMetadata; +import com.google.cloud.resourcemanager.v3.UpdateFolderRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +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 Folders service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFoldersStub extends FoldersStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(UndeleteFolderMetadata.getDescriptor()) + .add(Folder.getDescriptor()) + .add(UpdateFolderMetadata.getDescriptor()) + .add(DeleteFolderMetadata.getDescriptor()) + .add(MoveFolderMetadata.getDescriptor()) + .add(CreateFolderMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor getFolderMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/GetFolder") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=folders/*}", + 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(Folder.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFoldersMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/ListFolders") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/folders", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "parent", request.getParent()); + serializer.putQueryParam( + fields, "showDeleted", request.getShowDeleted()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFoldersResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + searchFoldersMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/SearchFolders") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/folders:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "query", request.getQuery()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchFoldersResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createFolderMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/CreateFolder") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/folders", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("folder", request.getFolder())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateFolderRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateFolderMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/UpdateFolder") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{folder.name=folders/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "folder.name", request.getFolder().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("folder", request.getFolder())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateFolderRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + moveFolderMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/MoveFolder") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=folders/*}:move", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (MoveFolderRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteFolderMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/DeleteFolder") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=folders/*}", + 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( + (DeleteFolderRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + undeleteFolderMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/UndeleteFolder") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=folders/*}:undelete", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UndeleteFolderRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=folders/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=folders/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Folders/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=folders/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getFolderCallable; + private final UnaryCallable listFoldersCallable; + private final UnaryCallable + listFoldersPagedCallable; + private final UnaryCallable searchFoldersCallable; + private final UnaryCallable + searchFoldersPagedCallable; + private final UnaryCallable createFolderCallable; + private final OperationCallable + createFolderOperationCallable; + private final UnaryCallable updateFolderCallable; + private final OperationCallable + updateFolderOperationCallable; + private final UnaryCallable moveFolderCallable; + private final OperationCallable + moveFolderOperationCallable; + private final UnaryCallable deleteFolderCallable; + private final OperationCallable + deleteFolderOperationCallable; + private final UnaryCallable undeleteFolderCallable; + private final OperationCallable + undeleteFolderOperationCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonFoldersStub create(FoldersStubSettings settings) throws IOException { + return new HttpJsonFoldersStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFoldersStub create(ClientContext clientContext) throws IOException { + return new HttpJsonFoldersStub(FoldersStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFoldersStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFoldersStub( + FoldersStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFoldersStub, 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 HttpJsonFoldersStub(FoldersStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonFoldersCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFoldersStub, 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 HttpJsonFoldersStub( + FoldersStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings getFolderTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFolderMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFoldersTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFoldersMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + searchFoldersTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchFoldersMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createFolderTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createFolderMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFolderTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFolderMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings moveFolderTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(moveFolderMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteFolderTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteFolderMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings undeleteFolderTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(undeleteFolderMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getFolderCallable = + callableFactory.createUnaryCallable( + getFolderTransportSettings, settings.getFolderSettings(), clientContext); + this.listFoldersCallable = + callableFactory.createUnaryCallable( + listFoldersTransportSettings, settings.listFoldersSettings(), clientContext); + this.listFoldersPagedCallable = + callableFactory.createPagedCallable( + listFoldersTransportSettings, settings.listFoldersSettings(), clientContext); + this.searchFoldersCallable = + callableFactory.createUnaryCallable( + searchFoldersTransportSettings, settings.searchFoldersSettings(), clientContext); + this.searchFoldersPagedCallable = + callableFactory.createPagedCallable( + searchFoldersTransportSettings, settings.searchFoldersSettings(), clientContext); + this.createFolderCallable = + callableFactory.createUnaryCallable( + createFolderTransportSettings, settings.createFolderSettings(), clientContext); + this.createFolderOperationCallable = + callableFactory.createOperationCallable( + createFolderTransportSettings, + settings.createFolderOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateFolderCallable = + callableFactory.createUnaryCallable( + updateFolderTransportSettings, settings.updateFolderSettings(), clientContext); + this.updateFolderOperationCallable = + callableFactory.createOperationCallable( + updateFolderTransportSettings, + settings.updateFolderOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.moveFolderCallable = + callableFactory.createUnaryCallable( + moveFolderTransportSettings, settings.moveFolderSettings(), clientContext); + this.moveFolderOperationCallable = + callableFactory.createOperationCallable( + moveFolderTransportSettings, + settings.moveFolderOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteFolderCallable = + callableFactory.createUnaryCallable( + deleteFolderTransportSettings, settings.deleteFolderSettings(), clientContext); + this.deleteFolderOperationCallable = + callableFactory.createOperationCallable( + deleteFolderTransportSettings, + settings.deleteFolderOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.undeleteFolderCallable = + callableFactory.createUnaryCallable( + undeleteFolderTransportSettings, settings.undeleteFolderSettings(), clientContext); + this.undeleteFolderOperationCallable = + callableFactory.createOperationCallable( + undeleteFolderTransportSettings, + settings.undeleteFolderOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getFolderMethodDescriptor); + methodDescriptors.add(listFoldersMethodDescriptor); + methodDescriptors.add(searchFoldersMethodDescriptor); + methodDescriptors.add(createFolderMethodDescriptor); + methodDescriptors.add(updateFolderMethodDescriptor); + methodDescriptors.add(moveFolderMethodDescriptor); + methodDescriptors.add(deleteFolderMethodDescriptor); + methodDescriptors.add(undeleteFolderMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable getFolderCallable() { + return getFolderCallable; + } + + @Override + public UnaryCallable listFoldersCallable() { + return listFoldersCallable; + } + + @Override + public UnaryCallable listFoldersPagedCallable() { + return listFoldersPagedCallable; + } + + @Override + public UnaryCallable searchFoldersCallable() { + return searchFoldersCallable; + } + + @Override + public UnaryCallable + searchFoldersPagedCallable() { + return searchFoldersPagedCallable; + } + + @Override + public UnaryCallable createFolderCallable() { + return createFolderCallable; + } + + @Override + public OperationCallable + createFolderOperationCallable() { + return createFolderOperationCallable; + } + + @Override + public UnaryCallable updateFolderCallable() { + return updateFolderCallable; + } + + @Override + public OperationCallable + updateFolderOperationCallable() { + return updateFolderOperationCallable; + } + + @Override + public UnaryCallable moveFolderCallable() { + return moveFolderCallable; + } + + @Override + public OperationCallable + moveFolderOperationCallable() { + return moveFolderOperationCallable; + } + + @Override + public UnaryCallable deleteFolderCallable() { + return deleteFolderCallable; + } + + @Override + public OperationCallable + deleteFolderOperationCallable() { + return deleteFolderOperationCallable; + } + + @Override + public UnaryCallable undeleteFolderCallable() { + return undeleteFolderCallable; + } + + @Override + public OperationCallable + undeleteFolderOperationCallable() { + return undeleteFolderOperationCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsCallableFactory.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsCallableFactory.java new file mode 100644 index 000000000000..b8b6a6906a91 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsCallableFactory.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.resourcemanager.v3.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 Organizations service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOrganizationsCallableFactory + 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsStub.java new file mode 100644 index 000000000000..a9cb9e86fdb3 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonOrganizationsStub.java @@ -0,0 +1,428 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.stub; + +import static com.google.cloud.resourcemanager.v3.OrganizationsClient.SearchOrganizationsPagedResponse; + +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.resourcemanager.v3.GetOrganizationRequest; +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.SearchOrganizationsRequest; +import com.google.cloud.resourcemanager.v3.SearchOrganizationsResponse; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +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 Organizations service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOrganizationsStub extends OrganizationsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getOrganizationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Organizations/GetOrganization") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=organizations/*}", + 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(Organization.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + searchOrganizationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.resourcemanager.v3.Organizations/SearchOrganizations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/organizations:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "query", request.getQuery()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchOrganizationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Organizations/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=organizations/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Organizations/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=organizations/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Organizations/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=organizations/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getOrganizationCallable; + private final UnaryCallable + searchOrganizationsCallable; + private final UnaryCallable + searchOrganizationsPagedCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOrganizationsStub create(OrganizationsStubSettings settings) + throws IOException { + return new HttpJsonOrganizationsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOrganizationsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOrganizationsStub( + OrganizationsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOrganizationsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOrganizationsStub( + OrganizationsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonOrganizationsStub, 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 HttpJsonOrganizationsStub( + OrganizationsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOrganizationsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOrganizationsStub, 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 HttpJsonOrganizationsStub( + OrganizationsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getOrganizationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOrganizationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + searchOrganizationsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(searchOrganizationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getOrganizationCallable = + callableFactory.createUnaryCallable( + getOrganizationTransportSettings, settings.getOrganizationSettings(), clientContext); + this.searchOrganizationsCallable = + callableFactory.createUnaryCallable( + searchOrganizationsTransportSettings, + settings.searchOrganizationsSettings(), + clientContext); + this.searchOrganizationsPagedCallable = + callableFactory.createPagedCallable( + searchOrganizationsTransportSettings, + settings.searchOrganizationsSettings(), + clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getOrganizationMethodDescriptor); + methodDescriptors.add(searchOrganizationsMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getOrganizationCallable() { + return getOrganizationCallable; + } + + @Override + public UnaryCallable + searchOrganizationsCallable() { + return searchOrganizationsCallable; + } + + @Override + public UnaryCallable + searchOrganizationsPagedCallable() { + return searchOrganizationsPagedCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsCallableFactory.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsCallableFactory.java new file mode 100644 index 000000000000..7bb81a45a8cc --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsCallableFactory.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.resourcemanager.v3.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 Projects service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProjectsCallableFactory + 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsStub.java new file mode 100644 index 000000000000..a605aa35d426 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonProjectsStub.java @@ -0,0 +1,848 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.stub; + +import static com.google.cloud.resourcemanager.v3.ProjectsClient.ListProjectsPagedResponse; +import static com.google.cloud.resourcemanager.v3.ProjectsClient.SearchProjectsPagedResponse; + +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.resourcemanager.v3.CreateProjectMetadata; +import com.google.cloud.resourcemanager.v3.CreateProjectRequest; +import com.google.cloud.resourcemanager.v3.DeleteProjectMetadata; +import com.google.cloud.resourcemanager.v3.DeleteProjectRequest; +import com.google.cloud.resourcemanager.v3.GetProjectRequest; +import com.google.cloud.resourcemanager.v3.ListProjectsRequest; +import com.google.cloud.resourcemanager.v3.ListProjectsResponse; +import com.google.cloud.resourcemanager.v3.MoveProjectMetadata; +import com.google.cloud.resourcemanager.v3.MoveProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.SearchProjectsRequest; +import com.google.cloud.resourcemanager.v3.SearchProjectsResponse; +import com.google.cloud.resourcemanager.v3.UndeleteProjectMetadata; +import com.google.cloud.resourcemanager.v3.UndeleteProjectRequest; +import com.google.cloud.resourcemanager.v3.UpdateProjectMetadata; +import com.google.cloud.resourcemanager.v3.UpdateProjectRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +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 Projects service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonProjectsStub extends ProjectsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Project.getDescriptor()) + .add(CreateProjectMetadata.getDescriptor()) + .add(UpdateProjectMetadata.getDescriptor()) + .add(MoveProjectMetadata.getDescriptor()) + .add(UndeleteProjectMetadata.getDescriptor()) + .add(DeleteProjectMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor getProjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/GetProject") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=projects/*}", + 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(Project.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listProjectsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/ListProjects") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/projects", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "parent", request.getParent()); + serializer.putQueryParam( + fields, "showDeleted", request.getShowDeleted()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProjectsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + searchProjectsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/SearchProjects") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/projects:search", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "query", request.getQuery()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SearchProjectsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createProjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/CreateProject") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/projects", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("project", request.getProject())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateProjectRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateProjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/UpdateProject") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{project.name=projects/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "project.name", request.getProject().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("project", request.getProject())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateProjectRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + moveProjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/MoveProject") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=projects/*}:move", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (MoveProjectRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteProjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/DeleteProject") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=projects/*}", + 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( + (DeleteProjectRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + undeleteProjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/UndeleteProject") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=projects/*}:undelete", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UndeleteProjectRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=projects/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=projects/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.Projects/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=projects/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getProjectCallable; + private final UnaryCallable listProjectsCallable; + private final UnaryCallable + listProjectsPagedCallable; + private final UnaryCallable searchProjectsCallable; + private final UnaryCallable + searchProjectsPagedCallable; + private final UnaryCallable createProjectCallable; + private final OperationCallable + createProjectOperationCallable; + private final UnaryCallable updateProjectCallable; + private final OperationCallable + updateProjectOperationCallable; + private final UnaryCallable moveProjectCallable; + private final OperationCallable + moveProjectOperationCallable; + private final UnaryCallable deleteProjectCallable; + private final OperationCallable + deleteProjectOperationCallable; + private final UnaryCallable undeleteProjectCallable; + private final OperationCallable + undeleteProjectOperationCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonProjectsStub create(ProjectsStubSettings settings) + throws IOException { + return new HttpJsonProjectsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonProjectsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonProjectsStub( + ProjectsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonProjectsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonProjectsStub( + ProjectsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonProjectsStub, 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 HttpJsonProjectsStub(ProjectsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonProjectsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonProjectsStub, 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 HttpJsonProjectsStub( + ProjectsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings getProjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getProjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listProjectsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProjectsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + searchProjectsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(searchProjectsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createProjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createProjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateProjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateProjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings moveProjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(moveProjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteProjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteProjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings undeleteProjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(undeleteProjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getProjectCallable = + callableFactory.createUnaryCallable( + getProjectTransportSettings, settings.getProjectSettings(), clientContext); + this.listProjectsCallable = + callableFactory.createUnaryCallable( + listProjectsTransportSettings, settings.listProjectsSettings(), clientContext); + this.listProjectsPagedCallable = + callableFactory.createPagedCallable( + listProjectsTransportSettings, settings.listProjectsSettings(), clientContext); + this.searchProjectsCallable = + callableFactory.createUnaryCallable( + searchProjectsTransportSettings, settings.searchProjectsSettings(), clientContext); + this.searchProjectsPagedCallable = + callableFactory.createPagedCallable( + searchProjectsTransportSettings, settings.searchProjectsSettings(), clientContext); + this.createProjectCallable = + callableFactory.createUnaryCallable( + createProjectTransportSettings, settings.createProjectSettings(), clientContext); + this.createProjectOperationCallable = + callableFactory.createOperationCallable( + createProjectTransportSettings, + settings.createProjectOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateProjectCallable = + callableFactory.createUnaryCallable( + updateProjectTransportSettings, settings.updateProjectSettings(), clientContext); + this.updateProjectOperationCallable = + callableFactory.createOperationCallable( + updateProjectTransportSettings, + settings.updateProjectOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.moveProjectCallable = + callableFactory.createUnaryCallable( + moveProjectTransportSettings, settings.moveProjectSettings(), clientContext); + this.moveProjectOperationCallable = + callableFactory.createOperationCallable( + moveProjectTransportSettings, + settings.moveProjectOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteProjectCallable = + callableFactory.createUnaryCallable( + deleteProjectTransportSettings, settings.deleteProjectSettings(), clientContext); + this.deleteProjectOperationCallable = + callableFactory.createOperationCallable( + deleteProjectTransportSettings, + settings.deleteProjectOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.undeleteProjectCallable = + callableFactory.createUnaryCallable( + undeleteProjectTransportSettings, settings.undeleteProjectSettings(), clientContext); + this.undeleteProjectOperationCallable = + callableFactory.createOperationCallable( + undeleteProjectTransportSettings, + settings.undeleteProjectOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getProjectMethodDescriptor); + methodDescriptors.add(listProjectsMethodDescriptor); + methodDescriptors.add(searchProjectsMethodDescriptor); + methodDescriptors.add(createProjectMethodDescriptor); + methodDescriptors.add(updateProjectMethodDescriptor); + methodDescriptors.add(moveProjectMethodDescriptor); + methodDescriptors.add(deleteProjectMethodDescriptor); + methodDescriptors.add(undeleteProjectMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable getProjectCallable() { + return getProjectCallable; + } + + @Override + public UnaryCallable listProjectsCallable() { + return listProjectsCallable; + } + + @Override + public UnaryCallable listProjectsPagedCallable() { + return listProjectsPagedCallable; + } + + @Override + public UnaryCallable searchProjectsCallable() { + return searchProjectsCallable; + } + + @Override + public UnaryCallable + searchProjectsPagedCallable() { + return searchProjectsPagedCallable; + } + + @Override + public UnaryCallable createProjectCallable() { + return createProjectCallable; + } + + @Override + public OperationCallable + createProjectOperationCallable() { + return createProjectOperationCallable; + } + + @Override + public UnaryCallable updateProjectCallable() { + return updateProjectCallable; + } + + @Override + public OperationCallable + updateProjectOperationCallable() { + return updateProjectOperationCallable; + } + + @Override + public UnaryCallable moveProjectCallable() { + return moveProjectCallable; + } + + @Override + public OperationCallable + moveProjectOperationCallable() { + return moveProjectOperationCallable; + } + + @Override + public UnaryCallable deleteProjectCallable() { + return deleteProjectCallable; + } + + @Override + public OperationCallable + deleteProjectOperationCallable() { + return deleteProjectOperationCallable; + } + + @Override + public UnaryCallable undeleteProjectCallable() { + return undeleteProjectCallable; + } + + @Override + public OperationCallable + undeleteProjectOperationCallable() { + return undeleteProjectOperationCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsCallableFactory.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsCallableFactory.java new file mode 100644 index 000000000000..c81a977bbdf4 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsCallableFactory.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.resourcemanager.v3.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 TagBindings service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTagBindingsCallableFactory + 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsStub.java new file mode 100644 index 000000000000..4934305c4749 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagBindingsStub.java @@ -0,0 +1,365 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.stub; + +import static com.google.cloud.resourcemanager.v3.TagBindingsClient.ListTagBindingsPagedResponse; + +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.resourcemanager.v3.CreateTagBindingMetadata; +import com.google.cloud.resourcemanager.v3.CreateTagBindingRequest; +import com.google.cloud.resourcemanager.v3.DeleteTagBindingMetadata; +import com.google.cloud.resourcemanager.v3.DeleteTagBindingRequest; +import com.google.cloud.resourcemanager.v3.ListTagBindingsRequest; +import com.google.cloud.resourcemanager.v3.ListTagBindingsResponse; +import com.google.cloud.resourcemanager.v3.TagBinding; +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 TagBindings service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTagBindingsStub extends TagBindingsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(TagBinding.getDescriptor()) + .add(DeleteTagBindingMetadata.getDescriptor()) + .add(CreateTagBindingMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listTagBindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagBindings/ListTagBindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/tagBindings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "parent", request.getParent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTagBindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createTagBindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagBindings/CreateTagBinding") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/tagBindings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("tagBinding", request.getTagBinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateTagBindingRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteTagBindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagBindings/DeleteTagBinding") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=tagBindings/**}", + 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( + (DeleteTagBindingRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listTagBindingsCallable; + private final UnaryCallable + listTagBindingsPagedCallable; + private final UnaryCallable createTagBindingCallable; + private final OperationCallable + createTagBindingOperationCallable; + private final UnaryCallable deleteTagBindingCallable; + private final OperationCallable + deleteTagBindingOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonTagBindingsStub create(TagBindingsStubSettings settings) + throws IOException { + return new HttpJsonTagBindingsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonTagBindingsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonTagBindingsStub( + TagBindingsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonTagBindingsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonTagBindingsStub( + TagBindingsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonTagBindingsStub, 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 HttpJsonTagBindingsStub(TagBindingsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonTagBindingsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonTagBindingsStub, 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 HttpJsonTagBindingsStub( + TagBindingsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listTagBindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTagBindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createTagBindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createTagBindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteTagBindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteTagBindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listTagBindingsCallable = + callableFactory.createUnaryCallable( + listTagBindingsTransportSettings, settings.listTagBindingsSettings(), clientContext); + this.listTagBindingsPagedCallable = + callableFactory.createPagedCallable( + listTagBindingsTransportSettings, settings.listTagBindingsSettings(), clientContext); + this.createTagBindingCallable = + callableFactory.createUnaryCallable( + createTagBindingTransportSettings, settings.createTagBindingSettings(), clientContext); + this.createTagBindingOperationCallable = + callableFactory.createOperationCallable( + createTagBindingTransportSettings, + settings.createTagBindingOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteTagBindingCallable = + callableFactory.createUnaryCallable( + deleteTagBindingTransportSettings, settings.deleteTagBindingSettings(), clientContext); + this.deleteTagBindingOperationCallable = + callableFactory.createOperationCallable( + deleteTagBindingTransportSettings, + settings.deleteTagBindingOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listTagBindingsMethodDescriptor); + methodDescriptors.add(createTagBindingMethodDescriptor); + methodDescriptors.add(deleteTagBindingMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listTagBindingsCallable() { + return listTagBindingsCallable; + } + + @Override + public UnaryCallable + listTagBindingsPagedCallable() { + return listTagBindingsPagedCallable; + } + + @Override + public UnaryCallable createTagBindingCallable() { + return createTagBindingCallable; + } + + @Override + public OperationCallable + createTagBindingOperationCallable() { + return createTagBindingOperationCallable; + } + + @Override + public UnaryCallable deleteTagBindingCallable() { + return deleteTagBindingCallable; + } + + @Override + public OperationCallable + deleteTagBindingOperationCallable() { + return deleteTagBindingOperationCallable; + } + + @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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysCallableFactory.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysCallableFactory.java new file mode 100644 index 000000000000..e97f56207a6d --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysCallableFactory.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.resourcemanager.v3.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 TagKeys service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTagKeysCallableFactory + 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysStub.java new file mode 100644 index 000000000000..6327f35a278e --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagKeysStub.java @@ -0,0 +1,644 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.stub; + +import static com.google.cloud.resourcemanager.v3.TagKeysClient.ListTagKeysPagedResponse; + +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.resourcemanager.v3.CreateTagKeyMetadata; +import com.google.cloud.resourcemanager.v3.CreateTagKeyRequest; +import com.google.cloud.resourcemanager.v3.DeleteTagKeyMetadata; +import com.google.cloud.resourcemanager.v3.DeleteTagKeyRequest; +import com.google.cloud.resourcemanager.v3.GetTagKeyRequest; +import com.google.cloud.resourcemanager.v3.ListTagKeysRequest; +import com.google.cloud.resourcemanager.v3.ListTagKeysResponse; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.UpdateTagKeyMetadata; +import com.google.cloud.resourcemanager.v3.UpdateTagKeyRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +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 TagKeys service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTagKeysStub extends TagKeysStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(TagKey.getDescriptor()) + .add(UpdateTagKeyMetadata.getDescriptor()) + .add(CreateTagKeyMetadata.getDescriptor()) + .add(DeleteTagKeyMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listTagKeysMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/ListTagKeys") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/tagKeys", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "parent", request.getParent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTagKeysResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getTagKeyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/GetTagKey") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=tagKeys/*}", + 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(TagKey.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createTagKeyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/CreateTagKey") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/tagKeys", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("tagKey", request.getTagKey())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateTagKeyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateTagKeyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/UpdateTagKey") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{tagKey.name=tagKeys/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "tagKey.name", request.getTagKey().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("tagKey", request.getTagKey())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateTagKeyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteTagKeyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/DeleteTagKey") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=tagKeys/*}", + 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, "etag", request.getEtag()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteTagKeyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=tagKeys/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=tagKeys/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagKeys/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=tagKeys/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listTagKeysCallable; + private final UnaryCallable + listTagKeysPagedCallable; + private final UnaryCallable getTagKeyCallable; + private final UnaryCallable createTagKeyCallable; + private final OperationCallable + createTagKeyOperationCallable; + private final UnaryCallable updateTagKeyCallable; + private final OperationCallable + updateTagKeyOperationCallable; + private final UnaryCallable deleteTagKeyCallable; + private final OperationCallable + deleteTagKeyOperationCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonTagKeysStub create(TagKeysStubSettings settings) throws IOException { + return new HttpJsonTagKeysStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonTagKeysStub create(ClientContext clientContext) throws IOException { + return new HttpJsonTagKeysStub(TagKeysStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonTagKeysStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonTagKeysStub( + TagKeysStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonTagKeysStub, 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 HttpJsonTagKeysStub(TagKeysStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonTagKeysCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonTagKeysStub, 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 HttpJsonTagKeysStub( + TagKeysStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listTagKeysTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTagKeysMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getTagKeyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getTagKeyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createTagKeyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createTagKeyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateTagKeyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateTagKeyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteTagKeyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteTagKeyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listTagKeysCallable = + callableFactory.createUnaryCallable( + listTagKeysTransportSettings, settings.listTagKeysSettings(), clientContext); + this.listTagKeysPagedCallable = + callableFactory.createPagedCallable( + listTagKeysTransportSettings, settings.listTagKeysSettings(), clientContext); + this.getTagKeyCallable = + callableFactory.createUnaryCallable( + getTagKeyTransportSettings, settings.getTagKeySettings(), clientContext); + this.createTagKeyCallable = + callableFactory.createUnaryCallable( + createTagKeyTransportSettings, settings.createTagKeySettings(), clientContext); + this.createTagKeyOperationCallable = + callableFactory.createOperationCallable( + createTagKeyTransportSettings, + settings.createTagKeyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateTagKeyCallable = + callableFactory.createUnaryCallable( + updateTagKeyTransportSettings, settings.updateTagKeySettings(), clientContext); + this.updateTagKeyOperationCallable = + callableFactory.createOperationCallable( + updateTagKeyTransportSettings, + settings.updateTagKeyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteTagKeyCallable = + callableFactory.createUnaryCallable( + deleteTagKeyTransportSettings, settings.deleteTagKeySettings(), clientContext); + this.deleteTagKeyOperationCallable = + callableFactory.createOperationCallable( + deleteTagKeyTransportSettings, + settings.deleteTagKeyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listTagKeysMethodDescriptor); + methodDescriptors.add(getTagKeyMethodDescriptor); + methodDescriptors.add(createTagKeyMethodDescriptor); + methodDescriptors.add(updateTagKeyMethodDescriptor); + methodDescriptors.add(deleteTagKeyMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listTagKeysCallable() { + return listTagKeysCallable; + } + + @Override + public UnaryCallable listTagKeysPagedCallable() { + return listTagKeysPagedCallable; + } + + @Override + public UnaryCallable getTagKeyCallable() { + return getTagKeyCallable; + } + + @Override + public UnaryCallable createTagKeyCallable() { + return createTagKeyCallable; + } + + @Override + public OperationCallable + createTagKeyOperationCallable() { + return createTagKeyOperationCallable; + } + + @Override + public UnaryCallable updateTagKeyCallable() { + return updateTagKeyCallable; + } + + @Override + public OperationCallable + updateTagKeyOperationCallable() { + return updateTagKeyOperationCallable; + } + + @Override + public UnaryCallable deleteTagKeyCallable() { + return deleteTagKeyCallable; + } + + @Override + public OperationCallable + deleteTagKeyOperationCallable() { + return deleteTagKeyOperationCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesCallableFactory.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesCallableFactory.java new file mode 100644 index 000000000000..cda18daaf21a --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesCallableFactory.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.resourcemanager.v3.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 TagValues service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTagValuesCallableFactory + 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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesStub.java new file mode 100644 index 000000000000..52ebee836d2d --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/HttpJsonTagValuesStub.java @@ -0,0 +1,651 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.stub; + +import static com.google.cloud.resourcemanager.v3.TagValuesClient.ListTagValuesPagedResponse; + +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.resourcemanager.v3.CreateTagValueMetadata; +import com.google.cloud.resourcemanager.v3.CreateTagValueRequest; +import com.google.cloud.resourcemanager.v3.DeleteTagValueMetadata; +import com.google.cloud.resourcemanager.v3.DeleteTagValueRequest; +import com.google.cloud.resourcemanager.v3.GetTagValueRequest; +import com.google.cloud.resourcemanager.v3.ListTagValuesRequest; +import com.google.cloud.resourcemanager.v3.ListTagValuesResponse; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.UpdateTagValueMetadata; +import com.google.cloud.resourcemanager.v3.UpdateTagValueRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +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 TagValues service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTagValuesStub extends TagValuesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(TagValue.getDescriptor()) + .add(CreateTagValueMetadata.getDescriptor()) + .add(UpdateTagValueMetadata.getDescriptor()) + .add(DeleteTagValueMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listTagValuesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/ListTagValues") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/tagValues", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "parent", request.getParent()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTagValuesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getTagValueMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/GetTagValue") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=tagValues/*}", + 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(TagValue.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createTagValueMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/CreateTagValue") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/tagValues", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("tagValue", request.getTagValue())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateTagValueRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateTagValueMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/UpdateTagValue") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{tagValue.name=tagValues/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "tagValue.name", request.getTagValue().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("tagValue", request.getTagValue())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateTagValueRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteTagValueMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/DeleteTagValue") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=tagValues/*}", + 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, "etag", request.getEtag()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteTagValueRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=tagValues/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=tagValues/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.resourcemanager.v3.TagValues/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{resource=tagValues/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listTagValuesCallable; + private final UnaryCallable + listTagValuesPagedCallable; + private final UnaryCallable getTagValueCallable; + private final UnaryCallable createTagValueCallable; + private final OperationCallable + createTagValueOperationCallable; + private final UnaryCallable updateTagValueCallable; + private final OperationCallable + updateTagValueOperationCallable; + private final UnaryCallable deleteTagValueCallable; + private final OperationCallable + deleteTagValueOperationCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonTagValuesStub create(TagValuesStubSettings settings) + throws IOException { + return new HttpJsonTagValuesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonTagValuesStub create(ClientContext clientContext) throws IOException { + return new HttpJsonTagValuesStub( + TagValuesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonTagValuesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonTagValuesStub( + TagValuesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonTagValuesStub, 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 HttpJsonTagValuesStub(TagValuesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonTagValuesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonTagValuesStub, 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 HttpJsonTagValuesStub( + TagValuesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listTagValuesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTagValuesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getTagValueTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getTagValueMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createTagValueTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createTagValueMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateTagValueTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateTagValueMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteTagValueTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteTagValueMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listTagValuesCallable = + callableFactory.createUnaryCallable( + listTagValuesTransportSettings, settings.listTagValuesSettings(), clientContext); + this.listTagValuesPagedCallable = + callableFactory.createPagedCallable( + listTagValuesTransportSettings, settings.listTagValuesSettings(), clientContext); + this.getTagValueCallable = + callableFactory.createUnaryCallable( + getTagValueTransportSettings, settings.getTagValueSettings(), clientContext); + this.createTagValueCallable = + callableFactory.createUnaryCallable( + createTagValueTransportSettings, settings.createTagValueSettings(), clientContext); + this.createTagValueOperationCallable = + callableFactory.createOperationCallable( + createTagValueTransportSettings, + settings.createTagValueOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateTagValueCallable = + callableFactory.createUnaryCallable( + updateTagValueTransportSettings, settings.updateTagValueSettings(), clientContext); + this.updateTagValueOperationCallable = + callableFactory.createOperationCallable( + updateTagValueTransportSettings, + settings.updateTagValueOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteTagValueCallable = + callableFactory.createUnaryCallable( + deleteTagValueTransportSettings, settings.deleteTagValueSettings(), clientContext); + this.deleteTagValueOperationCallable = + callableFactory.createOperationCallable( + deleteTagValueTransportSettings, + settings.deleteTagValueOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listTagValuesMethodDescriptor); + methodDescriptors.add(getTagValueMethodDescriptor); + methodDescriptors.add(createTagValueMethodDescriptor); + methodDescriptors.add(updateTagValueMethodDescriptor); + methodDescriptors.add(deleteTagValueMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listTagValuesCallable() { + return listTagValuesCallable; + } + + @Override + public UnaryCallable + listTagValuesPagedCallable() { + return listTagValuesPagedCallable; + } + + @Override + public UnaryCallable getTagValueCallable() { + return getTagValueCallable; + } + + @Override + public UnaryCallable createTagValueCallable() { + return createTagValueCallable; + } + + @Override + public OperationCallable + createTagValueOperationCallable() { + return createTagValueOperationCallable; + } + + @Override + public UnaryCallable updateTagValueCallable() { + return updateTagValueCallable; + } + + @Override + public OperationCallable + updateTagValueOperationCallable() { + return updateTagValueOperationCallable; + } + + @Override + public UnaryCallable deleteTagValueCallable() { + return deleteTagValueCallable; + } + + @Override + public OperationCallable + deleteTagValueOperationCallable() { + return deleteTagValueOperationCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @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-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/OrganizationsStubSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/OrganizationsStubSettings.java index ce30ab899178..afd05d345fed 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/OrganizationsStubSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/OrganizationsStubSettings.java @@ -27,6 +27,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; @@ -206,6 +209,11 @@ public OrganizationsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOrganizationsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOrganizationsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -238,18 +246,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(OrganizationsStubSettings.class)) @@ -257,11 +272,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(OrganizationsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OrganizationsStubSettings.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); @@ -395,6 +429,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 .getOrganizationSettings() diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStub.java index 3fec5afdcbcc..f4e34156aa8b 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStub.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStub.java @@ -57,7 +57,11 @@ public abstract class ProjectsStub 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 UnaryCallable getProjectCallable() { diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStubSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStubSettings.java index aaa730fd9ecb..34e3089ce142 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStubSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/ProjectsStubSettings.java @@ -29,6 +29,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; @@ -348,6 +351,11 @@ public ProjectsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcProjectsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonProjectsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -380,29 +388,54 @@ 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(ProjectsStubSettings.class)) .setTransportToken( 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(ProjectsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ProjectsStubSettings.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); @@ -600,6 +633,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 .getProjectSettings() diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStub.java index 523b49dcf377..2fccfb9f5e6e 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStub.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStub.java @@ -43,7 +43,11 @@ public abstract class TagBindingsStub 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 UnaryCallable diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStubSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStubSettings.java index ebc81848110f..08605efe0947 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStubSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagBindingsStubSettings.java @@ -28,6 +28,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; @@ -207,6 +210,11 @@ public TagBindingsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcTagBindingsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonTagBindingsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -239,18 +247,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(TagBindingsStubSettings.class)) @@ -258,11 +273,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(TagBindingsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return TagBindingsStubSettings.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); @@ -386,6 +420,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 .listTagBindingsSettings() diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStub.java index 663ec365bccd..bce7aff7a8c3 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStub.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStub.java @@ -50,7 +50,11 @@ public abstract class TagKeysStub 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 UnaryCallable listTagKeysPagedCallable() { diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStubSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStubSettings.java index c05eec02509d..8db81a7924f3 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStubSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagKeysStubSettings.java @@ -28,6 +28,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; @@ -248,6 +251,11 @@ public TagKeysStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcTagKeysStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonTagKeysStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -280,29 +288,54 @@ 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(TagKeysStubSettings.class)) .setTransportToken( 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(TagKeysStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return TagKeysStubSettings.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); @@ -465,6 +498,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 .listTagKeysSettings() diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStub.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStub.java index de59d0415222..7bfa0f9bf1ac 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStub.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStub.java @@ -50,7 +50,11 @@ public abstract class TagValuesStub 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 UnaryCallable diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStubSettings.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStubSettings.java index dd0840e548f7..3265ef6dc19b 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStubSettings.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/stub/TagValuesStubSettings.java @@ -28,6 +28,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; @@ -249,6 +252,11 @@ public TagValuesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcTagValuesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonTagValuesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -281,29 +289,54 @@ 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(TagValuesStubSettings.class)) .setTransportToken( 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(TagValuesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return TagValuesStubSettings.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); @@ -472,6 +505,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 .listTagValuesSettings() diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/FoldersClientHttpJsonTest.java b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/FoldersClientHttpJsonTest.java new file mode 100644 index 000000000000..a833d9ee3e54 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/FoldersClientHttpJsonTest.java @@ -0,0 +1,1197 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3; + +import static com.google.cloud.resourcemanager.v3.FoldersClient.ListFoldersPagedResponse; +import static com.google.cloud.resourcemanager.v3.FoldersClient.SearchFoldersPagedResponse; + +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.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.stub.HttpJsonFoldersStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +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 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 FoldersClientHttpJsonTest { + private static MockHttpService mockService; + private static FoldersClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFoldersStub.getMethodDescriptors(), FoldersSettings.getDefaultEndpoint()); + FoldersSettings settings = + FoldersSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FoldersSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FoldersClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getFolderTest() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + FolderName name = FolderName.of("[FOLDER]"); + + Folder actualResponse = client.getFolder(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 getFolderExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + client.getFolder(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFolderTest2() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "folders/folder-8133"; + + Folder actualResponse = client.getFolder(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 getFolderExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "folders/folder-8133"; + client.getFolder(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFoldersTest() throws Exception { + Folder responsesElement = Folder.newBuilder().build(); + ListFoldersResponse expectedResponse = + ListFoldersResponse.newBuilder() + .setNextPageToken("") + .addAllFolders(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName parent = FolderName.of("[FOLDER]"); + + ListFoldersPagedResponse pagedListResponse = client.listFolders(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFoldersList().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 listFoldersExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName parent = FolderName.of("[FOLDER]"); + client.listFolders(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFoldersTest2() throws Exception { + Folder responsesElement = Folder.newBuilder().build(); + ListFoldersResponse expectedResponse = + ListFoldersResponse.newBuilder() + .setNextPageToken("") + .addAllFolders(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListFoldersPagedResponse pagedListResponse = client.listFolders(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFoldersList().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 listFoldersExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listFolders(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchFoldersTest() throws Exception { + Folder responsesElement = Folder.newBuilder().build(); + SearchFoldersResponse expectedResponse = + SearchFoldersResponse.newBuilder() + .setNextPageToken("") + .addAllFolders(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String query = "query107944136"; + + SearchFoldersPagedResponse pagedListResponse = client.searchFolders(query); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFoldersList().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 searchFoldersExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String query = "query107944136"; + client.searchFolders(query); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFolderTest() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Folder folder = Folder.newBuilder().build(); + + Folder actualResponse = client.createFolderAsync(folder).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 createFolderExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Folder folder = Folder.newBuilder().build(); + client.createFolderAsync(folder).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateFolderTest() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Folder folder = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Folder actualResponse = client.updateFolderAsync(folder, 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 updateFolderExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Folder folder = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateFolderAsync(folder, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveFolderTest() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + FolderName name = FolderName.of("[FOLDER]"); + ResourceName destinationParent = FolderName.of("[FOLDER]"); + + Folder actualResponse = client.moveFolderAsync(name, destinationParent).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 moveFolderExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + ResourceName destinationParent = FolderName.of("[FOLDER]"); + client.moveFolderAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveFolderTest2() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + FolderName name = FolderName.of("[FOLDER]"); + String destinationParent = "destinationParent-1733659048"; + + Folder actualResponse = client.moveFolderAsync(name, destinationParent).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 moveFolderExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + String destinationParent = "destinationParent-1733659048"; + client.moveFolderAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveFolderTest3() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "folders/folder-8133"; + ResourceName destinationParent = FolderName.of("[FOLDER]"); + + Folder actualResponse = client.moveFolderAsync(name, destinationParent).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 moveFolderExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "folders/folder-8133"; + ResourceName destinationParent = FolderName.of("[FOLDER]"); + client.moveFolderAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveFolderTest4() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "folders/folder-8133"; + String destinationParent = "destinationParent-1733659048"; + + Folder actualResponse = client.moveFolderAsync(name, destinationParent).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 moveFolderExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "folders/folder-8133"; + String destinationParent = "destinationParent-1733659048"; + client.moveFolderAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteFolderTest() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + FolderName name = FolderName.of("[FOLDER]"); + + Folder actualResponse = client.deleteFolderAsync(name).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 deleteFolderExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + client.deleteFolderAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteFolderTest2() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "folders/folder-8133"; + + Folder actualResponse = client.deleteFolderAsync(name).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 deleteFolderExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "folders/folder-8133"; + client.deleteFolderAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeleteFolderTest() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeleteFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + FolderName name = FolderName.of("[FOLDER]"); + + Folder actualResponse = client.undeleteFolderAsync(name).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 undeleteFolderExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + client.undeleteFolderAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeleteFolderTest2() throws Exception { + Folder expectedResponse = + Folder.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setParent("parent-995424086") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeleteFolderTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "folders/folder-8133"; + + Folder actualResponse = client.undeleteFolderAsync(name).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 undeleteFolderExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "folders/folder-8133"; + client.undeleteFolderAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = FolderName.of("[FOLDER]"); + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = FolderName.of("[FOLDER]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "folders/folder-7438"; + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "folders/folder-7438"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = FolderName.of("[FOLDER]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = FolderName.of("[FOLDER]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "folders/folder-7438"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "folders/folder-7438"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = FolderName.of("[FOLDER]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = FolderName.of("[FOLDER]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "folders/folder-7438"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "folders/folder-7438"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/OrganizationsClientHttpJsonTest.java b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/OrganizationsClientHttpJsonTest.java new file mode 100644 index 000000000000..48c6588fe028 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/OrganizationsClientHttpJsonTest.java @@ -0,0 +1,509 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3; + +import static com.google.cloud.resourcemanager.v3.OrganizationsClient.SearchOrganizationsPagedResponse; + +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.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.stub.HttpJsonOrganizationsStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +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 OrganizationsClientHttpJsonTest { + private static MockHttpService mockService; + private static OrganizationsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOrganizationsStub.getMethodDescriptors(), + OrganizationsSettings.getDefaultEndpoint()); + OrganizationsSettings settings = + OrganizationsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OrganizationsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OrganizationsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getOrganizationTest() throws Exception { + Organization expectedResponse = + Organization.newBuilder() + .setName(OrganizationName.of("[ORGANIZATION]").toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + Organization actualResponse = client.getOrganization(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 getOrganizationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + client.getOrganization(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationTest2() throws Exception { + Organization expectedResponse = + Organization.newBuilder() + .setName(OrganizationName.of("[ORGANIZATION]").toString()) + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-1936"; + + Organization actualResponse = client.getOrganization(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 getOrganizationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-1936"; + client.getOrganization(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchOrganizationsTest() throws Exception { + Organization responsesElement = Organization.newBuilder().build(); + SearchOrganizationsResponse expectedResponse = + SearchOrganizationsResponse.newBuilder() + .setNextPageToken("") + .addAllOrganizations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String query = "query107944136"; + + SearchOrganizationsPagedResponse pagedListResponse = client.searchOrganizations(query); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOrganizationsList().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 searchOrganizationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String query = "query107944136"; + client.searchOrganizations(query); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-1245"; + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-1245"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + + Policy actualResponse = client.setIamPolicy(resource); + 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 setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + client.setIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-1245"; + + Policy actualResponse = client.setIamPolicy(resource); + 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 setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-1245"; + client.setIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-1245"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-1245"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/ProjectsClientHttpJsonTest.java b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/ProjectsClientHttpJsonTest.java new file mode 100644 index 000000000000..6e1fa1d7b1a5 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/ProjectsClientHttpJsonTest.java @@ -0,0 +1,1226 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3; + +import static com.google.cloud.resourcemanager.v3.ProjectsClient.ListProjectsPagedResponse; +import static com.google.cloud.resourcemanager.v3.ProjectsClient.SearchProjectsPagedResponse; + +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.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.stub.HttpJsonProjectsStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +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 ProjectsClientHttpJsonTest { + private static MockHttpService mockService; + private static ProjectsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonProjectsStub.getMethodDescriptors(), ProjectsSettings.getDefaultEndpoint()); + ProjectsSettings settings = + ProjectsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ProjectsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ProjectsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getProjectTest() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName name = ProjectName.of("[PROJECT]"); + + Project actualResponse = client.getProject(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 getProjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName name = ProjectName.of("[PROJECT]"); + client.getProject(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProjectTest2() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3664"; + + Project actualResponse = client.getProject(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 getProjectExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3664"; + client.getProject(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProjectsTest() throws Exception { + Project responsesElement = Project.newBuilder().build(); + ListProjectsResponse expectedResponse = + ListProjectsResponse.newBuilder() + .setNextPageToken("") + .addAllProjects(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName parent = FolderName.of("[FOLDER]"); + + ListProjectsPagedResponse pagedListResponse = client.listProjects(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProjectsList().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 listProjectsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName parent = FolderName.of("[FOLDER]"); + client.listProjects(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listProjectsTest2() throws Exception { + Project responsesElement = Project.newBuilder().build(); + ListProjectsResponse expectedResponse = + ListProjectsResponse.newBuilder() + .setNextPageToken("") + .addAllProjects(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListProjectsPagedResponse pagedListResponse = client.listProjects(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProjectsList().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 listProjectsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listProjects(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchProjectsTest() throws Exception { + Project responsesElement = Project.newBuilder().build(); + SearchProjectsResponse expectedResponse = + SearchProjectsResponse.newBuilder() + .setNextPageToken("") + .addAllProjects(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String query = "query107944136"; + + SearchProjectsPagedResponse pagedListResponse = client.searchProjects(query); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProjectsList().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 searchProjectsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String query = "query107944136"; + client.searchProjects(query); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createProjectTest() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Project project = Project.newBuilder().build(); + + Project actualResponse = client.createProjectAsync(project).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 createProjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Project project = Project.newBuilder().build(); + client.createProjectAsync(project).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateProjectTest() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Project project = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Project actualResponse = client.updateProjectAsync(project, 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 updateProjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Project project = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateProjectAsync(project, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveProjectTest() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName name = ProjectName.of("[PROJECT]"); + ResourceName destinationParent = ProjectName.of("[PROJECT]"); + + Project actualResponse = client.moveProjectAsync(name, destinationParent).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 moveProjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName name = ProjectName.of("[PROJECT]"); + ResourceName destinationParent = ProjectName.of("[PROJECT]"); + client.moveProjectAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveProjectTest2() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName name = ProjectName.of("[PROJECT]"); + String destinationParent = "destinationParent-1733659048"; + + Project actualResponse = client.moveProjectAsync(name, destinationParent).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 moveProjectExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName name = ProjectName.of("[PROJECT]"); + String destinationParent = "destinationParent-1733659048"; + client.moveProjectAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveProjectTest3() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3664"; + ResourceName destinationParent = ProjectName.of("[PROJECT]"); + + Project actualResponse = client.moveProjectAsync(name, destinationParent).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 moveProjectExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3664"; + ResourceName destinationParent = ProjectName.of("[PROJECT]"); + client.moveProjectAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void moveProjectTest4() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("moveProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3664"; + String destinationParent = "destinationParent-1733659048"; + + Project actualResponse = client.moveProjectAsync(name, destinationParent).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 moveProjectExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3664"; + String destinationParent = "destinationParent-1733659048"; + client.moveProjectAsync(name, destinationParent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteProjectTest() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName name = ProjectName.of("[PROJECT]"); + + Project actualResponse = client.deleteProjectAsync(name).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 deleteProjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName name = ProjectName.of("[PROJECT]"); + client.deleteProjectAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteProjectTest2() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3664"; + + Project actualResponse = client.deleteProjectAsync(name).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 deleteProjectExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3664"; + client.deleteProjectAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeleteProjectTest() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeleteProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName name = ProjectName.of("[PROJECT]"); + + Project actualResponse = client.undeleteProjectAsync(name).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 undeleteProjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName name = ProjectName.of("[PROJECT]"); + client.undeleteProjectAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void undeleteProjectTest2() throws Exception { + Project expectedResponse = + Project.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setParent("parent-995424086") + .setProjectId("projectId-894832108") + .setDisplayName("displayName1714148973") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("undeleteProjectTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3664"; + + Project actualResponse = client.undeleteProjectAsync(name).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 undeleteProjectExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3664"; + client.undeleteProjectAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = ProjectName.of("[PROJECT]"); + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = ProjectName.of("[PROJECT]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "projects/project-4963"; + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "projects/project-4963"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = ProjectName.of("[PROJECT]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = ProjectName.of("[PROJECT]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "projects/project-4963"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "projects/project-4963"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = ProjectName.of("[PROJECT]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = ProjectName.of("[PROJECT]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "projects/project-4963"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "projects/project-4963"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagBindingsClientHttpJsonTest.java b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagBindingsClientHttpJsonTest.java new file mode 100644 index 000000000000..314c2001fc77 --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagBindingsClientHttpJsonTest.java @@ -0,0 +1,323 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3; + +import static com.google.cloud.resourcemanager.v3.TagBindingsClient.ListTagBindingsPagedResponse; + +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.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.stub.HttpJsonTagBindingsStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.Arrays; +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 TagBindingsClientHttpJsonTest { + private static MockHttpService mockService; + private static TagBindingsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonTagBindingsStub.getMethodDescriptors(), + TagBindingsSettings.getDefaultEndpoint()); + TagBindingsSettings settings = + TagBindingsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + TagBindingsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = TagBindingsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listTagBindingsTest() throws Exception { + TagBinding responsesElement = TagBinding.newBuilder().build(); + ListTagBindingsResponse expectedResponse = + ListTagBindingsResponse.newBuilder() + .setNextPageToken("") + .addAllTagBindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName parent = FolderName.of("[FOLDER]"); + + ListTagBindingsPagedResponse pagedListResponse = client.listTagBindings(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTagBindingsList().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 listTagBindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName parent = FolderName.of("[FOLDER]"); + client.listTagBindings(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTagBindingsTest2() throws Exception { + TagBinding responsesElement = TagBinding.newBuilder().build(); + ListTagBindingsResponse expectedResponse = + ListTagBindingsResponse.newBuilder() + .setNextPageToken("") + .addAllTagBindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListTagBindingsPagedResponse pagedListResponse = client.listTagBindings(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTagBindingsList().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 listTagBindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listTagBindings(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createTagBindingTest() throws Exception { + TagBinding expectedResponse = + TagBinding.newBuilder() + .setName(TagBindingName.of("[TAG_BINDING]").toString()) + .setParent("parent-995424086") + .setTagValue("tagValue-772697609") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createTagBindingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagBinding tagBinding = TagBinding.newBuilder().build(); + + TagBinding actualResponse = client.createTagBindingAsync(tagBinding).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 createTagBindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagBinding tagBinding = TagBinding.newBuilder().build(); + client.createTagBindingAsync(tagBinding).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTagBindingTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTagBindingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagBindingName name = TagBindingName.of("[TAG_BINDING]"); + + client.deleteTagBindingAsync(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 deleteTagBindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagBindingName name = TagBindingName.of("[TAG_BINDING]"); + client.deleteTagBindingAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTagBindingTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTagBindingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "tagBindings/tagBinding-3342"; + + client.deleteTagBindingAsync(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 deleteTagBindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "tagBindings/tagBinding-3342"; + client.deleteTagBindingAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagKeysClientHttpJsonTest.java b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagKeysClientHttpJsonTest.java new file mode 100644 index 000000000000..15fdd068af1d --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagKeysClientHttpJsonTest.java @@ -0,0 +1,816 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3; + +import static com.google.cloud.resourcemanager.v3.TagKeysClient.ListTagKeysPagedResponse; + +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.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.stub.HttpJsonTagKeysStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +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 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 TagKeysClientHttpJsonTest { + private static MockHttpService mockService; + private static TagKeysClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonTagKeysStub.getMethodDescriptors(), TagKeysSettings.getDefaultEndpoint()); + TagKeysSettings settings = + TagKeysSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + TagKeysSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = TagKeysClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listTagKeysTest() throws Exception { + TagKey responsesElement = TagKey.newBuilder().build(); + ListTagKeysResponse expectedResponse = + ListTagKeysResponse.newBuilder() + .setNextPageToken("") + .addAllTagKeys(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName parent = FolderName.of("[FOLDER]"); + + ListTagKeysPagedResponse pagedListResponse = client.listTagKeys(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTagKeysList().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 listTagKeysExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName parent = FolderName.of("[FOLDER]"); + client.listTagKeys(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTagKeysTest2() throws Exception { + TagKey responsesElement = TagKey.newBuilder().build(); + ListTagKeysResponse expectedResponse = + ListTagKeysResponse.newBuilder() + .setNextPageToken("") + .addAllTagKeys(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListTagKeysPagedResponse pagedListResponse = client.listTagKeys(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTagKeysList().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 listTagKeysExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listTagKeys(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTagKeyTest() throws Exception { + TagKey expectedResponse = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + TagKeyName name = TagKeyName.of("[TAG_KEY]"); + + TagKey actualResponse = client.getTagKey(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 getTagKeyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagKeyName name = TagKeyName.of("[TAG_KEY]"); + client.getTagKey(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTagKeyTest2() throws Exception { + TagKey expectedResponse = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "tagKeys/tagKey-130"; + + TagKey actualResponse = client.getTagKey(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 getTagKeyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "tagKeys/tagKey-130"; + client.getTagKey(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createTagKeyTest() throws Exception { + TagKey expectedResponse = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createTagKeyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagKey tagKey = TagKey.newBuilder().build(); + + TagKey actualResponse = client.createTagKeyAsync(tagKey).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 createTagKeyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagKey tagKey = TagKey.newBuilder().build(); + client.createTagKeyAsync(tagKey).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateTagKeyTest() throws Exception { + TagKey expectedResponse = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateTagKeyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagKey tagKey = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + TagKey actualResponse = client.updateTagKeyAsync(tagKey, 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 updateTagKeyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagKey tagKey = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateTagKeyAsync(tagKey, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTagKeyTest() throws Exception { + TagKey expectedResponse = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTagKeyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagKeyName name = TagKeyName.of("[TAG_KEY]"); + + TagKey actualResponse = client.deleteTagKeyAsync(name).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 deleteTagKeyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagKeyName name = TagKeyName.of("[TAG_KEY]"); + client.deleteTagKeyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTagKeyTest2() throws Exception { + TagKey expectedResponse = + TagKey.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTagKeyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "tagKeys/tagKey-130"; + + TagKey actualResponse = client.deleteTagKeyAsync(name).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 deleteTagKeyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "tagKeys/tagKey-130"; + client.deleteTagKeyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "tagKeys/tagKey-8405"; + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "tagKeys/tagKey-8405"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "tagKeys/tagKey-8405"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "tagKeys/tagKey-8405"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "tagKeys/tagKey-8405"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "tagKeys/tagKey-8405"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagValuesClientHttpJsonTest.java b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagValuesClientHttpJsonTest.java new file mode 100644 index 000000000000..63759066bfee --- /dev/null +++ b/java-resourcemanager/google-cloud-resourcemanager/src/test/java/com/google/cloud/resourcemanager/v3/TagValuesClientHttpJsonTest.java @@ -0,0 +1,816 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3; + +import static com.google.cloud.resourcemanager.v3.TagValuesClient.ListTagValuesPagedResponse; + +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.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.stub.HttpJsonTagValuesStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +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 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 TagValuesClientHttpJsonTest { + private static MockHttpService mockService; + private static TagValuesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonTagValuesStub.getMethodDescriptors(), TagValuesSettings.getDefaultEndpoint()); + TagValuesSettings settings = + TagValuesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + TagValuesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = TagValuesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listTagValuesTest() throws Exception { + TagValue responsesElement = TagValue.newBuilder().build(); + ListTagValuesResponse expectedResponse = + ListTagValuesResponse.newBuilder() + .setNextPageToken("") + .addAllTagValues(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName parent = FolderName.of("[FOLDER]"); + + ListTagValuesPagedResponse pagedListResponse = client.listTagValues(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTagValuesList().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 listTagValuesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName parent = FolderName.of("[FOLDER]"); + client.listTagValues(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTagValuesTest2() throws Exception { + TagValue responsesElement = TagValue.newBuilder().build(); + ListTagValuesResponse expectedResponse = + ListTagValuesResponse.newBuilder() + .setNextPageToken("") + .addAllTagValues(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListTagValuesPagedResponse pagedListResponse = client.listTagValues(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTagValuesList().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 listTagValuesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listTagValues(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTagValueTest() throws Exception { + TagValue expectedResponse = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + TagValueName name = TagValueName.of("[TAG_VALUE]"); + + TagValue actualResponse = client.getTagValue(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 getTagValueExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagValueName name = TagValueName.of("[TAG_VALUE]"); + client.getTagValue(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTagValueTest2() throws Exception { + TagValue expectedResponse = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "tagValues/tagValue-268"; + + TagValue actualResponse = client.getTagValue(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 getTagValueExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "tagValues/tagValue-268"; + client.getTagValue(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createTagValueTest() throws Exception { + TagValue expectedResponse = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createTagValueTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagValue tagValue = TagValue.newBuilder().build(); + + TagValue actualResponse = client.createTagValueAsync(tagValue).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 createTagValueExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagValue tagValue = TagValue.newBuilder().build(); + client.createTagValueAsync(tagValue).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateTagValueTest() throws Exception { + TagValue expectedResponse = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateTagValueTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagValue tagValue = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + TagValue actualResponse = client.updateTagValueAsync(tagValue, 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 updateTagValueExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagValue tagValue = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateTagValueAsync(tagValue, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTagValueTest() throws Exception { + TagValue expectedResponse = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTagValueTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TagValueName name = TagValueName.of("[TAG_VALUE]"); + + TagValue actualResponse = client.deleteTagValueAsync(name).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 deleteTagValueExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TagValueName name = TagValueName.of("[TAG_VALUE]"); + client.deleteTagValueAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTagValueTest2() throws Exception { + TagValue expectedResponse = + TagValue.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setParent("parent-995424086") + .setShortName("shortName-2028219097") + .setNamespacedName("namespacedName-1877415788") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTagValueTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "tagValues/tagValue-268"; + + TagValue actualResponse = client.deleteTagValueAsync(name).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 deleteTagValueExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "tagValues/tagValue-268"; + client.deleteTagValueAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "tagValues/tagValue-7449"; + + Policy actualResponse = client.getIamPolicy(resource); + 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 getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "tagValues/tagValue-7449"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "tagValues/tagValue-7449"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + 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 setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "tagValues/tagValue-7449"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "tagValues/tagValue-7449"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + 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 testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "tagValues/tagValue-7449"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..6bbbe86a64dd --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.FoldersSettings; +import com.google.cloud.resourcemanager.v3.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. + FoldersSettings foldersSettings = + FoldersSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + FoldersClient foldersClient = FoldersClient.create(foldersSettings); + } +} +// [END resourcemanager_v3_generated_foldersclient_create_setcredentialsprovider_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider1.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..c12b8dd78098 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetCredentialsProvider1.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_create_setcredentialsprovider1_sync] +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.FoldersSettings; + +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. + FoldersSettings foldersSettings = + FoldersSettings.newBuilder() + .setTransportChannelProvider( + FoldersSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + FoldersClient foldersClient = FoldersClient.create(foldersSettings); + } +} +// [END resourcemanager_v3_generated_foldersclient_create_setcredentialsprovider1_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetEndpoint.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..3d24f6c936ca --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_create_setendpoint_sync] +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.FoldersSettings; +import com.google.cloud.resourcemanager.v3.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. + FoldersSettings foldersSettings = FoldersSettings.newBuilder().setEndpoint(myEndpoint).build(); + FoldersClient foldersClient = FoldersClient.create(foldersSettings); + } +} +// [END resourcemanager_v3_generated_foldersclient_create_setendpoint_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolder.java new file mode 100644 index 000000000000..bc4ee251a316 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_createfolder_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.CreateFolderRequest; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.longrunning.Operation; + +public class AsyncCreateFolder { + + public static void main(String[] args) throws Exception { + asyncCreateFolder(); + } + + public static void asyncCreateFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + CreateFolderRequest request = + CreateFolderRequest.newBuilder().setFolder(Folder.newBuilder().build()).build(); + ApiFuture future = foldersClient.createFolderCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_createfolder_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolderLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolderLRO.java new file mode 100644 index 000000000000..b937a3ee7e6d --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/AsyncCreateFolderLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_createfolder_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.CreateFolderMetadata; +import com.google.cloud.resourcemanager.v3.CreateFolderRequest; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class AsyncCreateFolderLRO { + + public static void main(String[] args) throws Exception { + asyncCreateFolderLRO(); + } + + public static void asyncCreateFolderLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + CreateFolderRequest request = + CreateFolderRequest.newBuilder().setFolder(Folder.newBuilder().build()).build(); + OperationFuture future = + foldersClient.createFolderOperationCallable().futureCall(request); + // Do something. + Folder response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_createfolder_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolder.java new file mode 100644 index 000000000000..f9f0f5794a82 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_createfolder_sync] +import com.google.cloud.resourcemanager.v3.CreateFolderRequest; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncCreateFolder { + + public static void main(String[] args) throws Exception { + syncCreateFolder(); + } + + public static void syncCreateFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + CreateFolderRequest request = + CreateFolderRequest.newBuilder().setFolder(Folder.newBuilder().build()).build(); + Folder response = foldersClient.createFolderAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_createfolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolderFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolderFolder.java new file mode 100644 index 000000000000..d7bcd4c5443a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/createfolder/SyncCreateFolderFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_createfolder_folder_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncCreateFolderFolder { + + public static void main(String[] args) throws Exception { + syncCreateFolderFolder(); + } + + public static void syncCreateFolderFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + Folder folder = Folder.newBuilder().build(); + Folder response = foldersClient.createFolderAsync(folder).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_createfolder_folder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolder.java new file mode 100644 index 000000000000..559111e8335c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_deletefolder_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.DeleteFolderRequest; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteFolder { + + public static void main(String[] args) throws Exception { + asyncDeleteFolder(); + } + + public static void asyncDeleteFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + DeleteFolderRequest request = + DeleteFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + ApiFuture future = foldersClient.deleteFolderCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_deletefolder_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolderLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolderLRO.java new file mode 100644 index 000000000000..14504e0e7c38 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/AsyncDeleteFolderLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_deletefolder_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.DeleteFolderMetadata; +import com.google.cloud.resourcemanager.v3.DeleteFolderRequest; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class AsyncDeleteFolderLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteFolderLRO(); + } + + public static void asyncDeleteFolderLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + DeleteFolderRequest request = + DeleteFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + OperationFuture future = + foldersClient.deleteFolderOperationCallable().futureCall(request); + // Do something. + Folder response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_deletefolder_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolder.java new file mode 100644 index 000000000000..f473a29501b6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_deletefolder_sync] +import com.google.cloud.resourcemanager.v3.DeleteFolderRequest; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncDeleteFolder { + + public static void main(String[] args) throws Exception { + syncDeleteFolder(); + } + + public static void syncDeleteFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + DeleteFolderRequest request = + DeleteFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + Folder response = foldersClient.deleteFolderAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_deletefolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderFoldername.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderFoldername.java new file mode 100644 index 000000000000..dba7668b50ad --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderFoldername.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_deletefolder_foldername_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncDeleteFolderFoldername { + + public static void main(String[] args) throws Exception { + syncDeleteFolderFoldername(); + } + + public static void syncDeleteFolderFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + FolderName name = FolderName.of("[FOLDER]"); + Folder response = foldersClient.deleteFolderAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_deletefolder_foldername_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderString.java new file mode 100644 index 000000000000..5cb28d720191 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/deletefolder/SyncDeleteFolderString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_deletefolder_string_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncDeleteFolderString { + + public static void main(String[] args) throws Exception { + syncDeleteFolderString(); + } + + public static void syncDeleteFolderString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String name = FolderName.of("[FOLDER]").toString(); + Folder response = foldersClient.deleteFolderAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_deletefolder_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/AsyncGetFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/AsyncGetFolder.java new file mode 100644 index 000000000000..69ec3fdcc14b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/AsyncGetFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getfolder_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.GetFolderRequest; + +public class AsyncGetFolder { + + public static void main(String[] args) throws Exception { + asyncGetFolder(); + } + + public static void asyncGetFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + GetFolderRequest request = + GetFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + ApiFuture future = foldersClient.getFolderCallable().futureCall(request); + // Do something. + Folder response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getfolder_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolder.java new file mode 100644 index 000000000000..27941e2b5717 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getfolder_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.GetFolderRequest; + +public class SyncGetFolder { + + public static void main(String[] args) throws Exception { + syncGetFolder(); + } + + public static void syncGetFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + GetFolderRequest request = + GetFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + Folder response = foldersClient.getFolder(request); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getfolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderFoldername.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderFoldername.java new file mode 100644 index 000000000000..5b45e0aefe3e --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderFoldername.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getfolder_foldername_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncGetFolderFoldername { + + public static void main(String[] args) throws Exception { + syncGetFolderFoldername(); + } + + public static void syncGetFolderFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + FolderName name = FolderName.of("[FOLDER]"); + Folder response = foldersClient.getFolder(name); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getfolder_foldername_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderString.java new file mode 100644 index 000000000000..adc261665e16 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getfolder/SyncGetFolderString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getfolder_string_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncGetFolderString { + + public static void main(String[] args) throws Exception { + syncGetFolderString(); + } + + public static void syncGetFolderString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String name = FolderName.of("[FOLDER]").toString(); + Folder response = foldersClient.getFolder(name); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getfolder_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/AsyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..6b7ffd9d498c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/AsyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(FolderName.of("[FOLDER]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = foldersClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..3eca2543ee85 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getiampolicy_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(FolderName.of("[FOLDER]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = foldersClient.getIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..7f9b1b9eb3df --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ResourceName resource = FolderName.of("[FOLDER]"); + Policy response = foldersClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getiampolicy_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..76c06411bfe6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/getiampolicy/SyncGetIamPolicyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_getiampolicy_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = foldersClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_getiampolicy_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFolders.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFolders.java new file mode 100644 index 000000000000..cdabf24fbb4c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFolders.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_listfolders_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.ListFoldersRequest; + +public class AsyncListFolders { + + public static void main(String[] args) throws Exception { + asyncListFolders(); + } + + public static void asyncListFolders() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ListFoldersRequest request = + ListFoldersRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setShowDeleted(true) + .build(); + ApiFuture future = foldersClient.listFoldersPagedCallable().futureCall(request); + // Do something. + for (Folder element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_listfolders_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFoldersPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFoldersPaged.java new file mode 100644 index 000000000000..712a02be8ae7 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/AsyncListFoldersPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_listfolders_paged_async] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.ListFoldersRequest; +import com.google.cloud.resourcemanager.v3.ListFoldersResponse; +import com.google.common.base.Strings; + +public class AsyncListFoldersPaged { + + public static void main(String[] args) throws Exception { + asyncListFoldersPaged(); + } + + public static void asyncListFoldersPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ListFoldersRequest request = + ListFoldersRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setShowDeleted(true) + .build(); + while (true) { + ListFoldersResponse response = foldersClient.listFoldersCallable().call(request); + for (Folder element : response.getFoldersList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_listfolders_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFolders.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFolders.java new file mode 100644 index 000000000000..58bd70c333e6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFolders.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_listfolders_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.ListFoldersRequest; + +public class SyncListFolders { + + public static void main(String[] args) throws Exception { + syncListFolders(); + } + + public static void syncListFolders() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ListFoldersRequest request = + ListFoldersRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setShowDeleted(true) + .build(); + for (Folder element : foldersClient.listFolders(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_listfolders_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersResourcename.java new file mode 100644 index 000000000000..e577f1f38d00 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_listfolders_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncListFoldersResourcename { + + public static void main(String[] args) throws Exception { + syncListFoldersResourcename(); + } + + public static void syncListFoldersResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ResourceName parent = FolderName.of("[FOLDER]"); + for (Folder element : foldersClient.listFolders(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_listfolders_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersString.java new file mode 100644 index 000000000000..67344f42d97f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/listfolders/SyncListFoldersString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_listfolders_string_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncListFoldersString { + + public static void main(String[] args) throws Exception { + syncListFoldersString(); + } + + public static void syncListFoldersString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String parent = FolderName.of("[FOLDER]").toString(); + for (Folder element : foldersClient.listFolders(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_listfolders_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolder.java new file mode 100644 index 000000000000..470d7f1d373a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.MoveFolderRequest; +import com.google.longrunning.Operation; + +public class AsyncMoveFolder { + + public static void main(String[] args) throws Exception { + asyncMoveFolder(); + } + + public static void asyncMoveFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + MoveFolderRequest request = + MoveFolderRequest.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setDestinationParent(FolderName.of("[FOLDER]").toString()) + .build(); + ApiFuture future = foldersClient.moveFolderCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolderLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolderLRO.java new file mode 100644 index 000000000000..6eb438af27a9 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/AsyncMoveFolderLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.MoveFolderMetadata; +import com.google.cloud.resourcemanager.v3.MoveFolderRequest; + +public class AsyncMoveFolderLRO { + + public static void main(String[] args) throws Exception { + asyncMoveFolderLRO(); + } + + public static void asyncMoveFolderLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + MoveFolderRequest request = + MoveFolderRequest.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setDestinationParent(FolderName.of("[FOLDER]").toString()) + .build(); + OperationFuture future = + foldersClient.moveFolderOperationCallable().futureCall(request); + // Do something. + Folder response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolder.java new file mode 100644 index 000000000000..1ad56d223088 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.MoveFolderRequest; + +public class SyncMoveFolder { + + public static void main(String[] args) throws Exception { + syncMoveFolder(); + } + + public static void syncMoveFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + MoveFolderRequest request = + MoveFolderRequest.newBuilder() + .setName(FolderName.of("[FOLDER]").toString()) + .setDestinationParent(FolderName.of("[FOLDER]").toString()) + .build(); + Folder response = foldersClient.moveFolderAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameResourcename.java new file mode 100644 index 000000000000..ebca16a0f200 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_foldernameresourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncMoveFolderFoldernameResourcename { + + public static void main(String[] args) throws Exception { + syncMoveFolderFoldernameResourcename(); + } + + public static void syncMoveFolderFoldernameResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + FolderName name = FolderName.of("[FOLDER]"); + ResourceName destinationParent = FolderName.of("[FOLDER]"); + Folder response = foldersClient.moveFolderAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_foldernameresourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameString.java new file mode 100644 index 000000000000..20a334c8ee30 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderFoldernameString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_foldernamestring_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncMoveFolderFoldernameString { + + public static void main(String[] args) throws Exception { + syncMoveFolderFoldernameString(); + } + + public static void syncMoveFolderFoldernameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + FolderName name = FolderName.of("[FOLDER]"); + String destinationParent = FolderName.of("[FOLDER]").toString(); + Folder response = foldersClient.moveFolderAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_foldernamestring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringResourcename.java new file mode 100644 index 000000000000..57568413d3c8 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_stringresourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncMoveFolderStringResourcename { + + public static void main(String[] args) throws Exception { + syncMoveFolderStringResourcename(); + } + + public static void syncMoveFolderStringResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String name = FolderName.of("[FOLDER]").toString(); + ResourceName destinationParent = FolderName.of("[FOLDER]"); + Folder response = foldersClient.moveFolderAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_stringresourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringString.java new file mode 100644 index 000000000000..0e53d503dfce --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/movefolder/SyncMoveFolderStringString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_movefolder_stringstring_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncMoveFolderStringString { + + public static void main(String[] args) throws Exception { + syncMoveFolderStringString(); + } + + public static void syncMoveFolderStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String name = FolderName.of("[FOLDER]").toString(); + String destinationParent = FolderName.of("[FOLDER]").toString(); + Folder response = foldersClient.moveFolderAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_movefolder_stringstring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFolders.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFolders.java new file mode 100644 index 000000000000..441ef3ef5427 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFolders.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_searchfolders_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.SearchFoldersRequest; + +public class AsyncSearchFolders { + + public static void main(String[] args) throws Exception { + asyncSearchFolders(); + } + + public static void asyncSearchFolders() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + SearchFoldersRequest request = + SearchFoldersRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setQuery("query107944136") + .build(); + ApiFuture future = foldersClient.searchFoldersPagedCallable().futureCall(request); + // Do something. + for (Folder element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_searchfolders_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFoldersPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFoldersPaged.java new file mode 100644 index 000000000000..9a29374d227e --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/AsyncSearchFoldersPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_searchfolders_paged_async] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.SearchFoldersRequest; +import com.google.cloud.resourcemanager.v3.SearchFoldersResponse; +import com.google.common.base.Strings; + +public class AsyncSearchFoldersPaged { + + public static void main(String[] args) throws Exception { + asyncSearchFoldersPaged(); + } + + public static void asyncSearchFoldersPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + SearchFoldersRequest request = + SearchFoldersRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setQuery("query107944136") + .build(); + while (true) { + SearchFoldersResponse response = foldersClient.searchFoldersCallable().call(request); + for (Folder element : response.getFoldersList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_searchfolders_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFolders.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFolders.java new file mode 100644 index 000000000000..ede91846f145 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFolders.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_searchfolders_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.SearchFoldersRequest; + +public class SyncSearchFolders { + + public static void main(String[] args) throws Exception { + syncSearchFolders(); + } + + public static void syncSearchFolders() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + SearchFoldersRequest request = + SearchFoldersRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setQuery("query107944136") + .build(); + for (Folder element : foldersClient.searchFolders(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_searchfolders_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFoldersString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFoldersString.java new file mode 100644 index 000000000000..c40b790401c1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/searchfolders/SyncSearchFoldersString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_searchfolders_string_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncSearchFoldersString { + + public static void main(String[] args) throws Exception { + syncSearchFoldersString(); + } + + public static void syncSearchFoldersString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String query = "query107944136"; + for (Folder element : foldersClient.searchFolders(query).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_foldersclient_searchfolders_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/AsyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..c4dab747a955 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/AsyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(FolderName.of("[FOLDER]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = foldersClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_setiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..5727d1f49529 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_setiampolicy_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(FolderName.of("[FOLDER]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = foldersClient.setIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_setiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..c6fcd384e279 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ResourceName resource = FolderName.of("[FOLDER]"); + Policy policy = Policy.newBuilder().build(); + Policy response = foldersClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_setiampolicy_resourcenamepolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..27c614dd6eaa --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/setiampolicy/SyncSetIamPolicyStringPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = foldersClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_setiampolicy_stringpolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/AsyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..c78c581aa108 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/AsyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(FolderName.of("[FOLDER]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + foldersClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_testiampermissions_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..445e06cb7e50 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_testiampermissions_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(FolderName.of("[FOLDER]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = foldersClient.testIamPermissions(request); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_testiampermissions_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..e145dffc4f0e --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + ResourceName resource = FolderName.of("[FOLDER]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = foldersClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_testiampermissions_resourcenameliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..0a9d5473bb75 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/testiampermissions/SyncTestIamPermissionsStringListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_testiampermissions_stringliststring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = foldersClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_testiampermissions_stringliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolder.java new file mode 100644 index 000000000000..ddc9a47a21e0 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_undeletefolder_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.UndeleteFolderRequest; +import com.google.longrunning.Operation; + +public class AsyncUndeleteFolder { + + public static void main(String[] args) throws Exception { + asyncUndeleteFolder(); + } + + public static void asyncUndeleteFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + UndeleteFolderRequest request = + UndeleteFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + ApiFuture future = foldersClient.undeleteFolderCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_undeletefolder_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolderLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolderLRO.java new file mode 100644 index 000000000000..87ac56d82728 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/AsyncUndeleteFolderLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_undeletefolder_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.UndeleteFolderMetadata; +import com.google.cloud.resourcemanager.v3.UndeleteFolderRequest; + +public class AsyncUndeleteFolderLRO { + + public static void main(String[] args) throws Exception { + asyncUndeleteFolderLRO(); + } + + public static void asyncUndeleteFolderLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + UndeleteFolderRequest request = + UndeleteFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + OperationFuture future = + foldersClient.undeleteFolderOperationCallable().futureCall(request); + // Do something. + Folder response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_undeletefolder_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolder.java new file mode 100644 index 000000000000..a9c744204703 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_undeletefolder_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.UndeleteFolderRequest; + +public class SyncUndeleteFolder { + + public static void main(String[] args) throws Exception { + syncUndeleteFolder(); + } + + public static void syncUndeleteFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + UndeleteFolderRequest request = + UndeleteFolderRequest.newBuilder().setName(FolderName.of("[FOLDER]").toString()).build(); + Folder response = foldersClient.undeleteFolderAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_undeletefolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderFoldername.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderFoldername.java new file mode 100644 index 000000000000..82ec019c540b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderFoldername.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_undeletefolder_foldername_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncUndeleteFolderFoldername { + + public static void main(String[] args) throws Exception { + syncUndeleteFolderFoldername(); + } + + public static void syncUndeleteFolderFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + FolderName name = FolderName.of("[FOLDER]"); + Folder response = foldersClient.undeleteFolderAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_undeletefolder_foldername_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderString.java new file mode 100644 index 000000000000..6a9bfebb9549 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/undeletefolder/SyncUndeleteFolderString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_undeletefolder_string_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.FoldersClient; + +public class SyncUndeleteFolderString { + + public static void main(String[] args) throws Exception { + syncUndeleteFolderString(); + } + + public static void syncUndeleteFolderString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + String name = FolderName.of("[FOLDER]").toString(); + Folder response = foldersClient.undeleteFolderAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_undeletefolder_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolder.java new file mode 100644 index 000000000000..c90fae7ad682 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_updatefolder_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.UpdateFolderRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFolder { + + public static void main(String[] args) throws Exception { + asyncUpdateFolder(); + } + + public static void asyncUpdateFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + UpdateFolderRequest request = + UpdateFolderRequest.newBuilder() + .setFolder(Folder.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = foldersClient.updateFolderCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_updatefolder_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolderLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolderLRO.java new file mode 100644 index 000000000000..c3d706252a73 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/AsyncUpdateFolderLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_updatefolder_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.UpdateFolderMetadata; +import com.google.cloud.resourcemanager.v3.UpdateFolderRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFolderLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateFolderLRO(); + } + + public static void asyncUpdateFolderLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + UpdateFolderRequest request = + UpdateFolderRequest.newBuilder() + .setFolder(Folder.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + foldersClient.updateFolderOperationCallable().futureCall(request); + // Do something. + Folder response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_updatefolder_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolder.java new file mode 100644 index 000000000000..68f8ab01423b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_updatefolder_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.cloud.resourcemanager.v3.UpdateFolderRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFolder { + + public static void main(String[] args) throws Exception { + syncUpdateFolder(); + } + + public static void syncUpdateFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + UpdateFolderRequest request = + UpdateFolderRequest.newBuilder() + .setFolder(Folder.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Folder response = foldersClient.updateFolderAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_updatefolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolderFolderFieldmask.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolderFolderFieldmask.java new file mode 100644 index 000000000000..77983bac02f1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/foldersclient/updatefolder/SyncUpdateFolderFolderFieldmask.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_foldersclient_updatefolder_folderfieldmask_sync] +import com.google.cloud.resourcemanager.v3.Folder; +import com.google.cloud.resourcemanager.v3.FoldersClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFolderFolderFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateFolderFolderFieldmask(); + } + + public static void syncUpdateFolderFolderFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (FoldersClient foldersClient = FoldersClient.create()) { + Folder folder = Folder.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Folder response = foldersClient.updateFolderAsync(folder, updateMask).get(); + } + } +} +// [END resourcemanager_v3_generated_foldersclient_updatefolder_folderfieldmask_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/folderssettings/getfolder/SyncGetFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/folderssettings/getfolder/SyncGetFolder.java new file mode 100644 index 000000000000..2b3bd22e1bbd --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/folderssettings/getfolder/SyncGetFolder.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_folderssettings_getfolder_sync] +import com.google.cloud.resourcemanager.v3.FoldersSettings; +import java.time.Duration; + +public class SyncGetFolder { + + public static void main(String[] args) throws Exception { + syncGetFolder(); + } + + public static void syncGetFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FoldersSettings.Builder foldersSettingsBuilder = FoldersSettings.newBuilder(); + foldersSettingsBuilder + .getFolderSettings() + .setRetrySettings( + foldersSettingsBuilder + .getFolderSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + FoldersSettings foldersSettings = foldersSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_folderssettings_getfolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..e75f80287c2e --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.cloud.resourcemanager.v3.OrganizationsSettings; +import com.google.cloud.resourcemanager.v3.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. + OrganizationsSettings organizationsSettings = + OrganizationsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings); + } +} +// [END resourcemanager_v3_generated_organizationsclient_create_setcredentialsprovider_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider1.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..73551b8ca55f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetCredentialsProvider1.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.cloud.resourcemanager.v3.OrganizationsSettings; + +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. + OrganizationsSettings organizationsSettings = + OrganizationsSettings.newBuilder() + .setTransportChannelProvider( + OrganizationsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings); + } +} +// [END resourcemanager_v3_generated_organizationsclient_create_setcredentialsprovider1_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetEndpoint.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..1228a33522db --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/create/SyncCreateSetEndpoint.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_create_setendpoint_sync] +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.cloud.resourcemanager.v3.OrganizationsSettings; +import com.google.cloud.resourcemanager.v3.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. + OrganizationsSettings organizationsSettings = + OrganizationsSettings.newBuilder().setEndpoint(myEndpoint).build(); + OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings); + } +} +// [END resourcemanager_v3_generated_organizationsclient_create_setendpoint_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/AsyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..f98c39c9e435 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/AsyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = organizationsClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..ce7bd48ea193 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getiampolicy_sync] +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = organizationsClient.getIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..29e53f122cb2 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + Policy response = organizationsClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getiampolicy_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..4c782faa1f37 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getiampolicy/SyncGetIamPolicyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getiampolicy_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = organizationsClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getiampolicy_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/AsyncGetOrganization.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/AsyncGetOrganization.java new file mode 100644 index 000000000000..6092cc2571bd --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/AsyncGetOrganization.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getorganization_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.GetOrganizationRequest; +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; + +public class AsyncGetOrganization { + + public static void main(String[] args) throws Exception { + asyncGetOrganization(); + } + + public static void asyncGetOrganization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + GetOrganizationRequest request = + GetOrganizationRequest.newBuilder() + .setName(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + organizationsClient.getOrganizationCallable().futureCall(request); + // Do something. + Organization response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getorganization_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganization.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganization.java new file mode 100644 index 000000000000..f4da29edbe33 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganization.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getorganization_sync] +import com.google.cloud.resourcemanager.v3.GetOrganizationRequest; +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; + +public class SyncGetOrganization { + + public static void main(String[] args) throws Exception { + syncGetOrganization(); + } + + public static void syncGetOrganization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + GetOrganizationRequest request = + GetOrganizationRequest.newBuilder() + .setName(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + Organization response = organizationsClient.getOrganization(request); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getorganization_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationOrganizationname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationOrganizationname.java new file mode 100644 index 000000000000..7130cfc494a9 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationOrganizationname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getorganization_organizationname_sync] +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; + +public class SyncGetOrganizationOrganizationname { + + public static void main(String[] args) throws Exception { + syncGetOrganizationOrganizationname(); + } + + public static void syncGetOrganizationOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + Organization response = organizationsClient.getOrganization(name); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getorganization_organizationname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationString.java new file mode 100644 index 000000000000..b7136d468bab --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/getorganization/SyncGetOrganizationString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_getorganization_string_sync] +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; + +public class SyncGetOrganizationString { + + public static void main(String[] args) throws Exception { + syncGetOrganizationString(); + } + + public static void syncGetOrganizationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + String name = OrganizationName.of("[ORGANIZATION]").toString(); + Organization response = organizationsClient.getOrganization(name); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_getorganization_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizations.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizations.java new file mode 100644 index 000000000000..cefa8dc08d5d --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizations.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_searchorganizations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.cloud.resourcemanager.v3.SearchOrganizationsRequest; + +public class AsyncSearchOrganizations { + + public static void main(String[] args) throws Exception { + asyncSearchOrganizations(); + } + + public static void asyncSearchOrganizations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + SearchOrganizationsRequest request = + SearchOrganizationsRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setQuery("query107944136") + .build(); + ApiFuture future = + organizationsClient.searchOrganizationsPagedCallable().futureCall(request); + // Do something. + for (Organization element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_searchorganizations_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizationsPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizationsPaged.java new file mode 100644 index 000000000000..6baa9430bdf5 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/AsyncSearchOrganizationsPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_searchorganizations_paged_async] +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.cloud.resourcemanager.v3.SearchOrganizationsRequest; +import com.google.cloud.resourcemanager.v3.SearchOrganizationsResponse; +import com.google.common.base.Strings; + +public class AsyncSearchOrganizationsPaged { + + public static void main(String[] args) throws Exception { + asyncSearchOrganizationsPaged(); + } + + public static void asyncSearchOrganizationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + SearchOrganizationsRequest request = + SearchOrganizationsRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setQuery("query107944136") + .build(); + while (true) { + SearchOrganizationsResponse response = + organizationsClient.searchOrganizationsCallable().call(request); + for (Organization element : response.getOrganizationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_searchorganizations_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizations.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizations.java new file mode 100644 index 000000000000..e6d5f11f7a75 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizations.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_searchorganizations_sync] +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.cloud.resourcemanager.v3.SearchOrganizationsRequest; + +public class SyncSearchOrganizations { + + public static void main(String[] args) throws Exception { + syncSearchOrganizations(); + } + + public static void syncSearchOrganizations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + SearchOrganizationsRequest request = + SearchOrganizationsRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setQuery("query107944136") + .build(); + for (Organization element : organizationsClient.searchOrganizations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_searchorganizations_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizationsString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizationsString.java new file mode 100644 index 000000000000..7a42bd287713 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/searchorganizations/SyncSearchOrganizationsString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_searchorganizations_string_sync] +import com.google.cloud.resourcemanager.v3.Organization; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; + +public class SyncSearchOrganizationsString { + + public static void main(String[] args) throws Exception { + syncSearchOrganizationsString(); + } + + public static void syncSearchOrganizationsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + String query = "query107944136"; + for (Organization element : organizationsClient.searchOrganizations(query).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_searchorganizations_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/AsyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..87bf7748dfdc --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/AsyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = organizationsClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_setiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..e50aeff5e492 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_setiampolicy_sync] +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = organizationsClient.setIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_setiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyResourcename.java new file mode 100644 index 000000000000..f8f2e4b077e8 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_setiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcename(); + } + + public static void syncSetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + Policy response = organizationsClient.setIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_setiampolicy_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyString.java new file mode 100644 index 000000000000..ead00cee247d --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/setiampolicy/SyncSetIamPolicyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_setiampolicy_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyString(); + } + + public static void syncSetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = organizationsClient.setIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_setiampolicy_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/AsyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..6c4337eeb271 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/AsyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + organizationsClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_testiampermissions_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..0b4378c4de5b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_testiampermissions_sync] +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = organizationsClient.testIamPermissions(request); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_testiampermissions_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..b26dea1ffd9a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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.resourcemanager.v3.samples; + +// [START +// resourcemanager_v3_generated_organizationsclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.OrganizationName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + organizationsClient.testIamPermissions(resource, permissions); + } + } +} +// [END +// resourcemanager_v3_generated_organizationsclient_testiampermissions_resourcenameliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..5d27d4869b89 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationsclient/testiampermissions/SyncTestIamPermissionsStringListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationsclient_testiampermissions_stringliststring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.OrganizationsClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OrganizationsClient organizationsClient = OrganizationsClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + organizationsClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_organizationsclient_testiampermissions_stringliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationssettings/getorganization/SyncGetOrganization.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationssettings/getorganization/SyncGetOrganization.java new file mode 100644 index 000000000000..2234b747f0b7 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/organizationssettings/getorganization/SyncGetOrganization.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_organizationssettings_getorganization_sync] +import com.google.cloud.resourcemanager.v3.OrganizationsSettings; +import java.time.Duration; + +public class SyncGetOrganization { + + public static void main(String[] args) throws Exception { + syncGetOrganization(); + } + + public static void syncGetOrganization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OrganizationsSettings.Builder organizationsSettingsBuilder = OrganizationsSettings.newBuilder(); + organizationsSettingsBuilder + .getOrganizationSettings() + .setRetrySettings( + organizationsSettingsBuilder + .getOrganizationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OrganizationsSettings organizationsSettings = organizationsSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_organizationssettings_getorganization_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..86865590f2c3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.ProjectsSettings; +import com.google.cloud.resourcemanager.v3.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. + ProjectsSettings projectsSettings = + ProjectsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ProjectsClient projectsClient = ProjectsClient.create(projectsSettings); + } +} +// [END resourcemanager_v3_generated_projectsclient_create_setcredentialsprovider_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider1.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..aaf2274471ed --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetCredentialsProvider1.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.ProjectsSettings; + +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. + ProjectsSettings projectsSettings = + ProjectsSettings.newBuilder() + .setTransportChannelProvider( + ProjectsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ProjectsClient projectsClient = ProjectsClient.create(projectsSettings); + } +} +// [END resourcemanager_v3_generated_projectsclient_create_setcredentialsprovider1_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetEndpoint.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..3e440235e0c2 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/create/SyncCreateSetEndpoint.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_create_setendpoint_sync] +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.ProjectsSettings; +import com.google.cloud.resourcemanager.v3.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. + ProjectsSettings projectsSettings = + ProjectsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ProjectsClient projectsClient = ProjectsClient.create(projectsSettings); + } +} +// [END resourcemanager_v3_generated_projectsclient_create_setendpoint_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProject.java new file mode 100644 index 000000000000..0dac5f8750bb --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_createproject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.CreateProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.longrunning.Operation; + +public class AsyncCreateProject { + + public static void main(String[] args) throws Exception { + asyncCreateProject(); + } + + public static void asyncCreateProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + CreateProjectRequest request = + CreateProjectRequest.newBuilder().setProject(Project.newBuilder().build()).build(); + ApiFuture future = projectsClient.createProjectCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_createproject_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProjectLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProjectLRO.java new file mode 100644 index 000000000000..e7fb979e2684 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/AsyncCreateProjectLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_createproject_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.CreateProjectMetadata; +import com.google.cloud.resourcemanager.v3.CreateProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class AsyncCreateProjectLRO { + + public static void main(String[] args) throws Exception { + asyncCreateProjectLRO(); + } + + public static void asyncCreateProjectLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + CreateProjectRequest request = + CreateProjectRequest.newBuilder().setProject(Project.newBuilder().build()).build(); + OperationFuture future = + projectsClient.createProjectOperationCallable().futureCall(request); + // Do something. + Project response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_createproject_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProject.java new file mode 100644 index 000000000000..223c05b859fc --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_createproject_sync] +import com.google.cloud.resourcemanager.v3.CreateProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncCreateProject { + + public static void main(String[] args) throws Exception { + syncCreateProject(); + } + + public static void syncCreateProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + CreateProjectRequest request = + CreateProjectRequest.newBuilder().setProject(Project.newBuilder().build()).build(); + Project response = projectsClient.createProjectAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_createproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProjectProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProjectProject.java new file mode 100644 index 000000000000..f1f1d47857fd --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/createproject/SyncCreateProjectProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_createproject_project_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncCreateProjectProject { + + public static void main(String[] args) throws Exception { + syncCreateProjectProject(); + } + + public static void syncCreateProjectProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + Project project = Project.newBuilder().build(); + Project response = projectsClient.createProjectAsync(project).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_createproject_project_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProject.java new file mode 100644 index 000000000000..526a8f01cda8 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_deleteproject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.DeleteProjectRequest; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteProject { + + public static void main(String[] args) throws Exception { + asyncDeleteProject(); + } + + public static void asyncDeleteProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + DeleteProjectRequest request = + DeleteProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = projectsClient.deleteProjectCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_deleteproject_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProjectLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProjectLRO.java new file mode 100644 index 000000000000..078615cbf1e0 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/AsyncDeleteProjectLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_deleteproject_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.DeleteProjectMetadata; +import com.google.cloud.resourcemanager.v3.DeleteProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class AsyncDeleteProjectLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteProjectLRO(); + } + + public static void asyncDeleteProjectLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + DeleteProjectRequest request = + DeleteProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build(); + OperationFuture future = + projectsClient.deleteProjectOperationCallable().futureCall(request); + // Do something. + Project response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_deleteproject_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProject.java new file mode 100644 index 000000000000..6481c3f6b335 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_deleteproject_sync] +import com.google.cloud.resourcemanager.v3.DeleteProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncDeleteProject { + + public static void main(String[] args) throws Exception { + syncDeleteProject(); + } + + public static void syncDeleteProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + DeleteProjectRequest request = + DeleteProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build(); + Project response = projectsClient.deleteProjectAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_deleteproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectProjectname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectProjectname.java new file mode 100644 index 000000000000..7f435c2d8f99 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectProjectname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_deleteproject_projectname_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncDeleteProjectProjectname { + + public static void main(String[] args) throws Exception { + syncDeleteProjectProjectname(); + } + + public static void syncDeleteProjectProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ProjectName name = ProjectName.of("[PROJECT]"); + Project response = projectsClient.deleteProjectAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_deleteproject_projectname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectString.java new file mode 100644 index 000000000000..a4c59bf3dbde --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/deleteproject/SyncDeleteProjectString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_deleteproject_string_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncDeleteProjectString { + + public static void main(String[] args) throws Exception { + syncDeleteProjectString(); + } + + public static void syncDeleteProjectString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String name = ProjectName.of("[PROJECT]").toString(); + Project response = projectsClient.deleteProjectAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_deleteproject_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/AsyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..b7907935db8f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/AsyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(ProjectName.of("[PROJECT]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = projectsClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..91b9709eb1e4 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getiampolicy_sync] +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(ProjectName.of("[PROJECT]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = projectsClient.getIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..9b1c680219ee --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ResourceName resource = ProjectName.of("[PROJECT]"); + Policy response = projectsClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getiampolicy_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..958b919c936e --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getiampolicy/SyncGetIamPolicyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getiampolicy_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = projectsClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getiampolicy_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/AsyncGetProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/AsyncGetProject.java new file mode 100644 index 000000000000..0dc502c0a049 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/AsyncGetProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getproject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.GetProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class AsyncGetProject { + + public static void main(String[] args) throws Exception { + asyncGetProject(); + } + + public static void asyncGetProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + GetProjectRequest request = + GetProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build(); + ApiFuture future = projectsClient.getProjectCallable().futureCall(request); + // Do something. + Project response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getproject_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProject.java new file mode 100644 index 000000000000..b375268b75a1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getproject_sync] +import com.google.cloud.resourcemanager.v3.GetProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncGetProject { + + public static void main(String[] args) throws Exception { + syncGetProject(); + } + + public static void syncGetProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + GetProjectRequest request = + GetProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build(); + Project response = projectsClient.getProject(request); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectProjectname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectProjectname.java new file mode 100644 index 000000000000..e1d53ec0a6d9 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectProjectname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getproject_projectname_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncGetProjectProjectname { + + public static void main(String[] args) throws Exception { + syncGetProjectProjectname(); + } + + public static void syncGetProjectProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ProjectName name = ProjectName.of("[PROJECT]"); + Project response = projectsClient.getProject(name); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getproject_projectname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectString.java new file mode 100644 index 000000000000..c79728610e4c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/getproject/SyncGetProjectString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_getproject_string_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncGetProjectString { + + public static void main(String[] args) throws Exception { + syncGetProjectString(); + } + + public static void syncGetProjectString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String name = ProjectName.of("[PROJECT]").toString(); + Project response = projectsClient.getProject(name); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_getproject_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjects.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjects.java new file mode 100644 index 000000000000..e6455367e674 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjects.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_listprojects_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListProjectsRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class AsyncListProjects { + + public static void main(String[] args) throws Exception { + asyncListProjects(); + } + + public static void asyncListProjects() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ListProjectsRequest request = + ListProjectsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .setShowDeleted(true) + .build(); + ApiFuture future = projectsClient.listProjectsPagedCallable().futureCall(request); + // Do something. + for (Project element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_listprojects_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjectsPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjectsPaged.java new file mode 100644 index 000000000000..ea9941320447 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/AsyncListProjectsPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_listprojects_paged_async] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListProjectsRequest; +import com.google.cloud.resourcemanager.v3.ListProjectsResponse; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.common.base.Strings; + +public class AsyncListProjectsPaged { + + public static void main(String[] args) throws Exception { + asyncListProjectsPaged(); + } + + public static void asyncListProjectsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ListProjectsRequest request = + ListProjectsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .setShowDeleted(true) + .build(); + while (true) { + ListProjectsResponse response = projectsClient.listProjectsCallable().call(request); + for (Project element : response.getProjectsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_listprojects_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjects.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjects.java new file mode 100644 index 000000000000..3746dcbe28f4 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjects.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_listprojects_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListProjectsRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncListProjects { + + public static void main(String[] args) throws Exception { + syncListProjects(); + } + + public static void syncListProjects() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ListProjectsRequest request = + ListProjectsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .setShowDeleted(true) + .build(); + for (Project element : projectsClient.listProjects(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_listprojects_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsResourcename.java new file mode 100644 index 000000000000..079cf57fa3be --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_listprojects_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncListProjectsResourcename { + + public static void main(String[] args) throws Exception { + syncListProjectsResourcename(); + } + + public static void syncListProjectsResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ResourceName parent = FolderName.of("[FOLDER]"); + for (Project element : projectsClient.listProjects(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_listprojects_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsString.java new file mode 100644 index 000000000000..cf4557b36c50 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/listprojects/SyncListProjectsString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_listprojects_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncListProjectsString { + + public static void main(String[] args) throws Exception { + syncListProjectsString(); + } + + public static void syncListProjectsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String parent = FolderName.of("[FOLDER]").toString(); + for (Project element : projectsClient.listProjects(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_listprojects_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProject.java new file mode 100644 index 000000000000..f36394e4f57f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.MoveProjectRequest; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.longrunning.Operation; + +public class AsyncMoveProject { + + public static void main(String[] args) throws Exception { + asyncMoveProject(); + } + + public static void asyncMoveProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + MoveProjectRequest request = + MoveProjectRequest.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setDestinationParent(ProjectName.of("[PROJECT]").toString()) + .build(); + ApiFuture future = projectsClient.moveProjectCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProjectLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProjectLRO.java new file mode 100644 index 000000000000..e84a0e19d20d --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/AsyncMoveProjectLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.MoveProjectMetadata; +import com.google.cloud.resourcemanager.v3.MoveProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class AsyncMoveProjectLRO { + + public static void main(String[] args) throws Exception { + asyncMoveProjectLRO(); + } + + public static void asyncMoveProjectLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + MoveProjectRequest request = + MoveProjectRequest.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setDestinationParent(ProjectName.of("[PROJECT]").toString()) + .build(); + OperationFuture future = + projectsClient.moveProjectOperationCallable().futureCall(request); + // Do something. + Project response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProject.java new file mode 100644 index 000000000000..4a8e7a101e3a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_sync] +import com.google.cloud.resourcemanager.v3.MoveProjectRequest; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncMoveProject { + + public static void main(String[] args) throws Exception { + syncMoveProject(); + } + + public static void syncMoveProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + MoveProjectRequest request = + MoveProjectRequest.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .setDestinationParent(ProjectName.of("[PROJECT]").toString()) + .build(); + Project response = projectsClient.moveProjectAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameResourcename.java new file mode 100644 index 000000000000..885e145c8b04 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_projectnameresourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncMoveProjectProjectnameResourcename { + + public static void main(String[] args) throws Exception { + syncMoveProjectProjectnameResourcename(); + } + + public static void syncMoveProjectProjectnameResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ProjectName name = ProjectName.of("[PROJECT]"); + ResourceName destinationParent = ProjectName.of("[PROJECT]"); + Project response = projectsClient.moveProjectAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_projectnameresourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameString.java new file mode 100644 index 000000000000..e30b52bd7fb0 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectProjectnameString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_projectnamestring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncMoveProjectProjectnameString { + + public static void main(String[] args) throws Exception { + syncMoveProjectProjectnameString(); + } + + public static void syncMoveProjectProjectnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ProjectName name = ProjectName.of("[PROJECT]"); + String destinationParent = FolderName.of("[FOLDER]").toString(); + Project response = projectsClient.moveProjectAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_projectnamestring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringResourcename.java new file mode 100644 index 000000000000..fcc92d5cf1ce --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_stringresourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncMoveProjectStringResourcename { + + public static void main(String[] args) throws Exception { + syncMoveProjectStringResourcename(); + } + + public static void syncMoveProjectStringResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String name = ProjectName.of("[PROJECT]").toString(); + ResourceName destinationParent = ProjectName.of("[PROJECT]"); + Project response = projectsClient.moveProjectAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_stringresourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringString.java new file mode 100644 index 000000000000..a7cf29f86f1d --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/moveproject/SyncMoveProjectStringString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_moveproject_stringstring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncMoveProjectStringString { + + public static void main(String[] args) throws Exception { + syncMoveProjectStringString(); + } + + public static void syncMoveProjectStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String name = ProjectName.of("[PROJECT]").toString(); + String destinationParent = FolderName.of("[FOLDER]").toString(); + Project response = projectsClient.moveProjectAsync(name, destinationParent).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_moveproject_stringstring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjects.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjects.java new file mode 100644 index 000000000000..7de3ef2e203b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjects.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_searchprojects_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.SearchProjectsRequest; + +public class AsyncSearchProjects { + + public static void main(String[] args) throws Exception { + asyncSearchProjects(); + } + + public static void asyncSearchProjects() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + SearchProjectsRequest request = + SearchProjectsRequest.newBuilder() + .setQuery("query107944136") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = projectsClient.searchProjectsPagedCallable().futureCall(request); + // Do something. + for (Project element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_searchprojects_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjectsPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjectsPaged.java new file mode 100644 index 000000000000..5a402bcf6ed3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/AsyncSearchProjectsPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_searchprojects_paged_async] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.SearchProjectsRequest; +import com.google.cloud.resourcemanager.v3.SearchProjectsResponse; +import com.google.common.base.Strings; + +public class AsyncSearchProjectsPaged { + + public static void main(String[] args) throws Exception { + asyncSearchProjectsPaged(); + } + + public static void asyncSearchProjectsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + SearchProjectsRequest request = + SearchProjectsRequest.newBuilder() + .setQuery("query107944136") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + SearchProjectsResponse response = projectsClient.searchProjectsCallable().call(request); + for (Project element : response.getProjectsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_searchprojects_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjects.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjects.java new file mode 100644 index 000000000000..cbd38942f237 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjects.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_searchprojects_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.SearchProjectsRequest; + +public class SyncSearchProjects { + + public static void main(String[] args) throws Exception { + syncSearchProjects(); + } + + public static void syncSearchProjects() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + SearchProjectsRequest request = + SearchProjectsRequest.newBuilder() + .setQuery("query107944136") + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Project element : projectsClient.searchProjects(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_searchprojects_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjectsString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjectsString.java new file mode 100644 index 000000000000..e625725345e9 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/searchprojects/SyncSearchProjectsString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_searchprojects_string_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncSearchProjectsString { + + public static void main(String[] args) throws Exception { + syncSearchProjectsString(); + } + + public static void syncSearchProjectsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String query = "query107944136"; + for (Project element : projectsClient.searchProjects(query).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_projectsclient_searchprojects_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/AsyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..06cc11fe4cde --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/AsyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(ProjectName.of("[PROJECT]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = projectsClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_setiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..aa0d3fd4db3b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_setiampolicy_sync] +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(ProjectName.of("[PROJECT]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = projectsClient.setIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_setiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..e3c79fd257bd --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ResourceName resource = ProjectName.of("[PROJECT]"); + Policy policy = Policy.newBuilder().build(); + Policy response = projectsClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_setiampolicy_resourcenamepolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..a31c2ec36a1c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/setiampolicy/SyncSetIamPolicyStringPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = projectsClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_setiampolicy_stringpolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/AsyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..0e37e419c937 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/AsyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(ProjectName.of("[PROJECT]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + projectsClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_testiampermissions_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..86c7e837b5a0 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_testiampermissions_sync] +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(ProjectName.of("[PROJECT]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = projectsClient.testIamPermissions(request); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_testiampermissions_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..3af3671f79ed --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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.resourcemanager.v3.samples; + +// [START +// resourcemanager_v3_generated_projectsclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ResourceName resource = ProjectName.of("[PROJECT]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + projectsClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_testiampermissions_resourcenameliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..bcab1fee89fe --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/testiampermissions/SyncTestIamPermissionsStringListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_testiampermissions_stringliststring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + projectsClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_testiampermissions_stringliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProject.java new file mode 100644 index 000000000000..ea419933ec39 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_undeleteproject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.UndeleteProjectRequest; +import com.google.longrunning.Operation; + +public class AsyncUndeleteProject { + + public static void main(String[] args) throws Exception { + asyncUndeleteProject(); + } + + public static void asyncUndeleteProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + UndeleteProjectRequest request = + UndeleteProjectRequest.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .build(); + ApiFuture future = projectsClient.undeleteProjectCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_undeleteproject_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProjectLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProjectLRO.java new file mode 100644 index 000000000000..c9b7ba07e583 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/AsyncUndeleteProjectLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_undeleteproject_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.UndeleteProjectMetadata; +import com.google.cloud.resourcemanager.v3.UndeleteProjectRequest; + +public class AsyncUndeleteProjectLRO { + + public static void main(String[] args) throws Exception { + asyncUndeleteProjectLRO(); + } + + public static void asyncUndeleteProjectLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + UndeleteProjectRequest request = + UndeleteProjectRequest.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .build(); + OperationFuture future = + projectsClient.undeleteProjectOperationCallable().futureCall(request); + // Do something. + Project response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_undeleteproject_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProject.java new file mode 100644 index 000000000000..b137865cec02 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_undeleteproject_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.UndeleteProjectRequest; + +public class SyncUndeleteProject { + + public static void main(String[] args) throws Exception { + syncUndeleteProject(); + } + + public static void syncUndeleteProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + UndeleteProjectRequest request = + UndeleteProjectRequest.newBuilder() + .setName(ProjectName.of("[PROJECT]").toString()) + .build(); + Project response = projectsClient.undeleteProjectAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_undeleteproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectProjectname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectProjectname.java new file mode 100644 index 000000000000..6abc880934a6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectProjectname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_undeleteproject_projectname_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncUndeleteProjectProjectname { + + public static void main(String[] args) throws Exception { + syncUndeleteProjectProjectname(); + } + + public static void syncUndeleteProjectProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + ProjectName name = ProjectName.of("[PROJECT]"); + Project response = projectsClient.undeleteProjectAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_undeleteproject_projectname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectString.java new file mode 100644 index 000000000000..14eac8e248ab --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/undeleteproject/SyncUndeleteProjectString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_undeleteproject_string_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectName; +import com.google.cloud.resourcemanager.v3.ProjectsClient; + +public class SyncUndeleteProjectString { + + public static void main(String[] args) throws Exception { + syncUndeleteProjectString(); + } + + public static void syncUndeleteProjectString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + String name = ProjectName.of("[PROJECT]").toString(); + Project response = projectsClient.undeleteProjectAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_undeleteproject_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProject.java new file mode 100644 index 000000000000..b69ba8148a2f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_updateproject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.UpdateProjectRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProject { + + public static void main(String[] args) throws Exception { + asyncUpdateProject(); + } + + public static void asyncUpdateProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + UpdateProjectRequest request = + UpdateProjectRequest.newBuilder() + .setProject(Project.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = projectsClient.updateProjectCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_updateproject_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProjectLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProjectLRO.java new file mode 100644 index 000000000000..4993012db596 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/AsyncUpdateProjectLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_updateproject_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.UpdateProjectMetadata; +import com.google.cloud.resourcemanager.v3.UpdateProjectRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateProjectLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateProjectLRO(); + } + + public static void asyncUpdateProjectLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + UpdateProjectRequest request = + UpdateProjectRequest.newBuilder() + .setProject(Project.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + projectsClient.updateProjectOperationCallable().futureCall(request); + // Do something. + Project response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_updateproject_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProject.java new file mode 100644 index 000000000000..a5a2772079d5 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_updateproject_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.cloud.resourcemanager.v3.UpdateProjectRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProject { + + public static void main(String[] args) throws Exception { + syncUpdateProject(); + } + + public static void syncUpdateProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + UpdateProjectRequest request = + UpdateProjectRequest.newBuilder() + .setProject(Project.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Project response = projectsClient.updateProjectAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_updateproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProjectProjectFieldmask.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProjectProjectFieldmask.java new file mode 100644 index 000000000000..52db091d9336 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectsclient/updateproject/SyncUpdateProjectProjectFieldmask.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectsclient_updateproject_projectfieldmask_sync] +import com.google.cloud.resourcemanager.v3.Project; +import com.google.cloud.resourcemanager.v3.ProjectsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateProjectProjectFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateProjectProjectFieldmask(); + } + + public static void syncUpdateProjectProjectFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ProjectsClient projectsClient = ProjectsClient.create()) { + Project project = Project.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Project response = projectsClient.updateProjectAsync(project, updateMask).get(); + } + } +} +// [END resourcemanager_v3_generated_projectsclient_updateproject_projectfieldmask_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectssettings/getproject/SyncGetProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectssettings/getproject/SyncGetProject.java new file mode 100644 index 000000000000..6b89d03ad065 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/projectssettings/getproject/SyncGetProject.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_projectssettings_getproject_sync] +import com.google.cloud.resourcemanager.v3.ProjectsSettings; +import java.time.Duration; + +public class SyncGetProject { + + public static void main(String[] args) throws Exception { + syncGetProject(); + } + + public static void syncGetProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProjectsSettings.Builder projectsSettingsBuilder = ProjectsSettings.newBuilder(); + projectsSettingsBuilder + .getProjectSettings() + .setRetrySettings( + projectsSettingsBuilder + .getProjectSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProjectsSettings projectsSettings = projectsSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_projectssettings_getproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/foldersstubsettings/getfolder/SyncGetFolder.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/foldersstubsettings/getfolder/SyncGetFolder.java new file mode 100644 index 000000000000..2436230baa63 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/foldersstubsettings/getfolder/SyncGetFolder.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.resourcemanager.v3.stub.samples; + +// [START resourcemanager_v3_generated_foldersstubsettings_getfolder_sync] +import com.google.cloud.resourcemanager.v3.stub.FoldersStubSettings; +import java.time.Duration; + +public class SyncGetFolder { + + public static void main(String[] args) throws Exception { + syncGetFolder(); + } + + public static void syncGetFolder() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + FoldersStubSettings.Builder foldersSettingsBuilder = FoldersStubSettings.newBuilder(); + foldersSettingsBuilder + .getFolderSettings() + .setRetrySettings( + foldersSettingsBuilder + .getFolderSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + FoldersStubSettings foldersSettings = foldersSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_foldersstubsettings_getfolder_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/organizationsstubsettings/getorganization/SyncGetOrganization.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/organizationsstubsettings/getorganization/SyncGetOrganization.java new file mode 100644 index 000000000000..0fd9d2825007 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/organizationsstubsettings/getorganization/SyncGetOrganization.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.resourcemanager.v3.stub.samples; + +// [START resourcemanager_v3_generated_organizationsstubsettings_getorganization_sync] +import com.google.cloud.resourcemanager.v3.stub.OrganizationsStubSettings; +import java.time.Duration; + +public class SyncGetOrganization { + + public static void main(String[] args) throws Exception { + syncGetOrganization(); + } + + public static void syncGetOrganization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OrganizationsStubSettings.Builder organizationsSettingsBuilder = + OrganizationsStubSettings.newBuilder(); + organizationsSettingsBuilder + .getOrganizationSettings() + .setRetrySettings( + organizationsSettingsBuilder + .getOrganizationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OrganizationsStubSettings organizationsSettings = organizationsSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_organizationsstubsettings_getorganization_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/projectsstubsettings/getproject/SyncGetProject.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/projectsstubsettings/getproject/SyncGetProject.java new file mode 100644 index 000000000000..bf01071b99a3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/projectsstubsettings/getproject/SyncGetProject.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.resourcemanager.v3.stub.samples; + +// [START resourcemanager_v3_generated_projectsstubsettings_getproject_sync] +import com.google.cloud.resourcemanager.v3.stub.ProjectsStubSettings; +import java.time.Duration; + +public class SyncGetProject { + + public static void main(String[] args) throws Exception { + syncGetProject(); + } + + public static void syncGetProject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ProjectsStubSettings.Builder projectsSettingsBuilder = ProjectsStubSettings.newBuilder(); + projectsSettingsBuilder + .getProjectSettings() + .setRetrySettings( + projectsSettingsBuilder + .getProjectSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ProjectsStubSettings projectsSettings = projectsSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_projectsstubsettings_getproject_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagbindingsstubsettings/listtagbindings/SyncListTagBindings.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagbindingsstubsettings/listtagbindings/SyncListTagBindings.java new file mode 100644 index 000000000000..93145dcad95c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagbindingsstubsettings/listtagbindings/SyncListTagBindings.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.resourcemanager.v3.stub.samples; + +// [START resourcemanager_v3_generated_tagbindingsstubsettings_listtagbindings_sync] +import com.google.cloud.resourcemanager.v3.stub.TagBindingsStubSettings; +import java.time.Duration; + +public class SyncListTagBindings { + + public static void main(String[] args) throws Exception { + syncListTagBindings(); + } + + public static void syncListTagBindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TagBindingsStubSettings.Builder tagBindingsSettingsBuilder = + TagBindingsStubSettings.newBuilder(); + tagBindingsSettingsBuilder + .listTagBindingsSettings() + .setRetrySettings( + tagBindingsSettingsBuilder + .listTagBindingsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TagBindingsStubSettings tagBindingsSettings = tagBindingsSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_tagbindingsstubsettings_listtagbindings_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagkeysstubsettings/gettagkey/SyncGetTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagkeysstubsettings/gettagkey/SyncGetTagKey.java new file mode 100644 index 000000000000..4433c1ccf465 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagkeysstubsettings/gettagkey/SyncGetTagKey.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.resourcemanager.v3.stub.samples; + +// [START resourcemanager_v3_generated_tagkeysstubsettings_gettagkey_sync] +import com.google.cloud.resourcemanager.v3.stub.TagKeysStubSettings; +import java.time.Duration; + +public class SyncGetTagKey { + + public static void main(String[] args) throws Exception { + syncGetTagKey(); + } + + public static void syncGetTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TagKeysStubSettings.Builder tagKeysSettingsBuilder = TagKeysStubSettings.newBuilder(); + tagKeysSettingsBuilder + .getTagKeySettings() + .setRetrySettings( + tagKeysSettingsBuilder + .getTagKeySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TagKeysStubSettings tagKeysSettings = tagKeysSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_tagkeysstubsettings_gettagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagvaluesstubsettings/gettagvalue/SyncGetTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagvaluesstubsettings/gettagvalue/SyncGetTagValue.java new file mode 100644 index 000000000000..d7dce38f879b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/stub/tagvaluesstubsettings/gettagvalue/SyncGetTagValue.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.resourcemanager.v3.stub.samples; + +// [START resourcemanager_v3_generated_tagvaluesstubsettings_gettagvalue_sync] +import com.google.cloud.resourcemanager.v3.stub.TagValuesStubSettings; +import java.time.Duration; + +public class SyncGetTagValue { + + public static void main(String[] args) throws Exception { + syncGetTagValue(); + } + + public static void syncGetTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TagValuesStubSettings.Builder tagValuesSettingsBuilder = TagValuesStubSettings.newBuilder(); + tagValuesSettingsBuilder + .getTagValueSettings() + .setRetrySettings( + tagValuesSettingsBuilder + .getTagValueSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TagValuesStubSettings tagValuesSettings = tagValuesSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_tagvaluesstubsettings_gettagvalue_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..3c3b34e9cce1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.cloud.resourcemanager.v3.TagBindingsSettings; +import com.google.cloud.resourcemanager.v3.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. + TagBindingsSettings tagBindingsSettings = + TagBindingsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings); + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_create_setcredentialsprovider_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider1.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..f519f011e9bf --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetCredentialsProvider1.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.cloud.resourcemanager.v3.TagBindingsSettings; + +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. + TagBindingsSettings tagBindingsSettings = + TagBindingsSettings.newBuilder() + .setTransportChannelProvider( + TagBindingsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings); + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_create_setcredentialsprovider1_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetEndpoint.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..d0f737f85533 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/create/SyncCreateSetEndpoint.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_create_setendpoint_sync] +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.cloud.resourcemanager.v3.TagBindingsSettings; +import com.google.cloud.resourcemanager.v3.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. + TagBindingsSettings tagBindingsSettings = + TagBindingsSettings.newBuilder().setEndpoint(myEndpoint).build(); + TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings); + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_create_setendpoint_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBinding.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBinding.java new file mode 100644 index 000000000000..fc4b2b7af87b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBinding.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_createtagbinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.CreateTagBindingRequest; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.longrunning.Operation; + +public class AsyncCreateTagBinding { + + public static void main(String[] args) throws Exception { + asyncCreateTagBinding(); + } + + public static void asyncCreateTagBinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + CreateTagBindingRequest request = + CreateTagBindingRequest.newBuilder() + .setTagBinding(TagBinding.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = + tagBindingsClient.createTagBindingCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_createtagbinding_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBindingLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBindingLRO.java new file mode 100644 index 000000000000..d08f6f4201c5 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/AsyncCreateTagBindingLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_createtagbinding_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.CreateTagBindingMetadata; +import com.google.cloud.resourcemanager.v3.CreateTagBindingRequest; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class AsyncCreateTagBindingLRO { + + public static void main(String[] args) throws Exception { + asyncCreateTagBindingLRO(); + } + + public static void asyncCreateTagBindingLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + CreateTagBindingRequest request = + CreateTagBindingRequest.newBuilder() + .setTagBinding(TagBinding.newBuilder().build()) + .setValidateOnly(true) + .build(); + OperationFuture future = + tagBindingsClient.createTagBindingOperationCallable().futureCall(request); + // Do something. + TagBinding response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_createtagbinding_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBinding.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBinding.java new file mode 100644 index 000000000000..6ba22006772a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBinding.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_createtagbinding_sync] +import com.google.cloud.resourcemanager.v3.CreateTagBindingRequest; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncCreateTagBinding { + + public static void main(String[] args) throws Exception { + syncCreateTagBinding(); + } + + public static void syncCreateTagBinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + CreateTagBindingRequest request = + CreateTagBindingRequest.newBuilder() + .setTagBinding(TagBinding.newBuilder().build()) + .setValidateOnly(true) + .build(); + TagBinding response = tagBindingsClient.createTagBindingAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_createtagbinding_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBindingTagbinding.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBindingTagbinding.java new file mode 100644 index 000000000000..bb9826157323 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/createtagbinding/SyncCreateTagBindingTagbinding.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_createtagbinding_tagbinding_sync] +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncCreateTagBindingTagbinding { + + public static void main(String[] args) throws Exception { + syncCreateTagBindingTagbinding(); + } + + public static void syncCreateTagBindingTagbinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + TagBinding tagBinding = TagBinding.newBuilder().build(); + TagBinding response = tagBindingsClient.createTagBindingAsync(tagBinding).get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_createtagbinding_tagbinding_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBinding.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBinding.java new file mode 100644 index 000000000000..cde0cb4f4371 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBinding.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.DeleteTagBindingRequest; +import com.google.cloud.resourcemanager.v3.TagBindingName; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteTagBinding { + + public static void main(String[] args) throws Exception { + asyncDeleteTagBinding(); + } + + public static void asyncDeleteTagBinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + DeleteTagBindingRequest request = + DeleteTagBindingRequest.newBuilder() + .setName(TagBindingName.of("[TAG_BINDING]").toString()) + .build(); + ApiFuture future = + tagBindingsClient.deleteTagBindingCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBindingLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBindingLRO.java new file mode 100644 index 000000000000..49d19ea607cc --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/AsyncDeleteTagBindingLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.DeleteTagBindingMetadata; +import com.google.cloud.resourcemanager.v3.DeleteTagBindingRequest; +import com.google.cloud.resourcemanager.v3.TagBindingName; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteTagBindingLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteTagBindingLRO(); + } + + public static void asyncDeleteTagBindingLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + DeleteTagBindingRequest request = + DeleteTagBindingRequest.newBuilder() + .setName(TagBindingName.of("[TAG_BINDING]").toString()) + .build(); + OperationFuture future = + tagBindingsClient.deleteTagBindingOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBinding.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBinding.java new file mode 100644 index 000000000000..dd1c043da2ca --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBinding.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_sync] +import com.google.cloud.resourcemanager.v3.DeleteTagBindingRequest; +import com.google.cloud.resourcemanager.v3.TagBindingName; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncDeleteTagBinding { + + public static void main(String[] args) throws Exception { + syncDeleteTagBinding(); + } + + public static void syncDeleteTagBinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + DeleteTagBindingRequest request = + DeleteTagBindingRequest.newBuilder() + .setName(TagBindingName.of("[TAG_BINDING]").toString()) + .build(); + tagBindingsClient.deleteTagBindingAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingString.java new file mode 100644 index 000000000000..f633987c9581 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_string_sync] +import com.google.cloud.resourcemanager.v3.TagBindingName; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncDeleteTagBindingString { + + public static void main(String[] args) throws Exception { + syncDeleteTagBindingString(); + } + + public static void syncDeleteTagBindingString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + String name = TagBindingName.of("[TAG_BINDING]").toString(); + tagBindingsClient.deleteTagBindingAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingTagbindingname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingTagbindingname.java new file mode 100644 index 000000000000..dd8852da2e8f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/deletetagbinding/SyncDeleteTagBindingTagbindingname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_tagbindingname_sync] +import com.google.cloud.resourcemanager.v3.TagBindingName; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncDeleteTagBindingTagbindingname { + + public static void main(String[] args) throws Exception { + syncDeleteTagBindingTagbindingname(); + } + + public static void syncDeleteTagBindingTagbindingname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + TagBindingName name = TagBindingName.of("[TAG_BINDING]"); + tagBindingsClient.deleteTagBindingAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_deletetagbinding_tagbindingname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindings.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindings.java new file mode 100644 index 000000000000..d9d2fc23aeff --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindings.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_listtagbindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagBindingsRequest; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class AsyncListTagBindings { + + public static void main(String[] args) throws Exception { + asyncListTagBindings(); + } + + public static void asyncListTagBindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + ListTagBindingsRequest request = + ListTagBindingsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + tagBindingsClient.listTagBindingsPagedCallable().futureCall(request); + // Do something. + for (TagBinding element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_listtagbindings_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindingsPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindingsPaged.java new file mode 100644 index 000000000000..4687f5bf77a2 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/AsyncListTagBindingsPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_listtagbindings_paged_async] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagBindingsRequest; +import com.google.cloud.resourcemanager.v3.ListTagBindingsResponse; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; +import com.google.common.base.Strings; + +public class AsyncListTagBindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListTagBindingsPaged(); + } + + public static void asyncListTagBindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + ListTagBindingsRequest request = + ListTagBindingsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListTagBindingsResponse response = + tagBindingsClient.listTagBindingsCallable().call(request); + for (TagBinding element : response.getTagBindingsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_listtagbindings_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindings.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindings.java new file mode 100644 index 000000000000..ccb975e57358 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindings.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_listtagbindings_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagBindingsRequest; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncListTagBindings { + + public static void main(String[] args) throws Exception { + syncListTagBindings(); + } + + public static void syncListTagBindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + ListTagBindingsRequest request = + ListTagBindingsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (TagBinding element : tagBindingsClient.listTagBindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_listtagbindings_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsResourcename.java new file mode 100644 index 000000000000..5ad9218ad752 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_listtagbindings_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncListTagBindingsResourcename { + + public static void main(String[] args) throws Exception { + syncListTagBindingsResourcename(); + } + + public static void syncListTagBindingsResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + ResourceName parent = FolderName.of("[FOLDER]"); + for (TagBinding element : tagBindingsClient.listTagBindings(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_listtagbindings_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsString.java new file mode 100644 index 000000000000..9cc240b1bd06 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingsclient/listtagbindings/SyncListTagBindingsString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingsclient_listtagbindings_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagBinding; +import com.google.cloud.resourcemanager.v3.TagBindingsClient; + +public class SyncListTagBindingsString { + + public static void main(String[] args) throws Exception { + syncListTagBindingsString(); + } + + public static void syncListTagBindingsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) { + String parent = FolderName.of("[FOLDER]").toString(); + for (TagBinding element : tagBindingsClient.listTagBindings(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagbindingsclient_listtagbindings_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingssettings/listtagbindings/SyncListTagBindings.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingssettings/listtagbindings/SyncListTagBindings.java new file mode 100644 index 000000000000..b41d75dc1465 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagbindingssettings/listtagbindings/SyncListTagBindings.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagbindingssettings_listtagbindings_sync] +import com.google.cloud.resourcemanager.v3.TagBindingsSettings; +import java.time.Duration; + +public class SyncListTagBindings { + + public static void main(String[] args) throws Exception { + syncListTagBindings(); + } + + public static void syncListTagBindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TagBindingsSettings.Builder tagBindingsSettingsBuilder = TagBindingsSettings.newBuilder(); + tagBindingsSettingsBuilder + .listTagBindingsSettings() + .setRetrySettings( + tagBindingsSettingsBuilder + .listTagBindingsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TagBindingsSettings tagBindingsSettings = tagBindingsSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_tagbindingssettings_listtagbindings_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..6885bdb9d037 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.cloud.resourcemanager.v3.TagKeysSettings; +import com.google.cloud.resourcemanager.v3.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. + TagKeysSettings tagKeysSettings = + TagKeysSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + TagKeysClient tagKeysClient = TagKeysClient.create(tagKeysSettings); + } +} +// [END resourcemanager_v3_generated_tagkeysclient_create_setcredentialsprovider_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider1.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..b5f93fa03cb8 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetCredentialsProvider1.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_create_setcredentialsprovider1_sync] +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.cloud.resourcemanager.v3.TagKeysSettings; + +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. + TagKeysSettings tagKeysSettings = + TagKeysSettings.newBuilder() + .setTransportChannelProvider( + TagKeysSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + TagKeysClient tagKeysClient = TagKeysClient.create(tagKeysSettings); + } +} +// [END resourcemanager_v3_generated_tagkeysclient_create_setcredentialsprovider1_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetEndpoint.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..564f0c1654d4 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_create_setendpoint_sync] +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.cloud.resourcemanager.v3.TagKeysSettings; +import com.google.cloud.resourcemanager.v3.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. + TagKeysSettings tagKeysSettings = TagKeysSettings.newBuilder().setEndpoint(myEndpoint).build(); + TagKeysClient tagKeysClient = TagKeysClient.create(tagKeysSettings); + } +} +// [END resourcemanager_v3_generated_tagkeysclient_create_setendpoint_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKey.java new file mode 100644 index 000000000000..fa86b8aa1f58 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_createtagkey_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.CreateTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.longrunning.Operation; + +public class AsyncCreateTagKey { + + public static void main(String[] args) throws Exception { + asyncCreateTagKey(); + } + + public static void asyncCreateTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + CreateTagKeyRequest request = + CreateTagKeyRequest.newBuilder() + .setTagKey(TagKey.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = tagKeysClient.createTagKeyCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_createtagkey_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKeyLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKeyLRO.java new file mode 100644 index 000000000000..2c7719868ace --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/AsyncCreateTagKeyLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_createtagkey_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.CreateTagKeyMetadata; +import com.google.cloud.resourcemanager.v3.CreateTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class AsyncCreateTagKeyLRO { + + public static void main(String[] args) throws Exception { + asyncCreateTagKeyLRO(); + } + + public static void asyncCreateTagKeyLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + CreateTagKeyRequest request = + CreateTagKeyRequest.newBuilder() + .setTagKey(TagKey.newBuilder().build()) + .setValidateOnly(true) + .build(); + OperationFuture future = + tagKeysClient.createTagKeyOperationCallable().futureCall(request); + // Do something. + TagKey response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_createtagkey_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKey.java new file mode 100644 index 000000000000..c786894af4eb --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_createtagkey_sync] +import com.google.cloud.resourcemanager.v3.CreateTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncCreateTagKey { + + public static void main(String[] args) throws Exception { + syncCreateTagKey(); + } + + public static void syncCreateTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + CreateTagKeyRequest request = + CreateTagKeyRequest.newBuilder() + .setTagKey(TagKey.newBuilder().build()) + .setValidateOnly(true) + .build(); + TagKey response = tagKeysClient.createTagKeyAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_createtagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKeyTagkey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKeyTagkey.java new file mode 100644 index 000000000000..16f245f9a69a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/createtagkey/SyncCreateTagKeyTagkey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_createtagkey_tagkey_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncCreateTagKeyTagkey { + + public static void main(String[] args) throws Exception { + syncCreateTagKeyTagkey(); + } + + public static void syncCreateTagKeyTagkey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + TagKey tagKey = TagKey.newBuilder().build(); + TagKey response = tagKeysClient.createTagKeyAsync(tagKey).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_createtagkey_tagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKey.java new file mode 100644 index 000000000000..1033df087e80 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_deletetagkey_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.DeleteTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteTagKey { + + public static void main(String[] args) throws Exception { + asyncDeleteTagKey(); + } + + public static void asyncDeleteTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + DeleteTagKeyRequest request = + DeleteTagKeyRequest.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + ApiFuture future = tagKeysClient.deleteTagKeyCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_deletetagkey_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKeyLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKeyLRO.java new file mode 100644 index 000000000000..f9448db4f1f9 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/AsyncDeleteTagKeyLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_deletetagkey_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.DeleteTagKeyMetadata; +import com.google.cloud.resourcemanager.v3.DeleteTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class AsyncDeleteTagKeyLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteTagKeyLRO(); + } + + public static void asyncDeleteTagKeyLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + DeleteTagKeyRequest request = + DeleteTagKeyRequest.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + OperationFuture future = + tagKeysClient.deleteTagKeyOperationCallable().futureCall(request); + // Do something. + TagKey response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_deletetagkey_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKey.java new file mode 100644 index 000000000000..5e3eea6c3432 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_deletetagkey_sync] +import com.google.cloud.resourcemanager.v3.DeleteTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncDeleteTagKey { + + public static void main(String[] args) throws Exception { + syncDeleteTagKey(); + } + + public static void syncDeleteTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + DeleteTagKeyRequest request = + DeleteTagKeyRequest.newBuilder() + .setName(TagKeyName.of("[TAG_KEY]").toString()) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + TagKey response = tagKeysClient.deleteTagKeyAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_deletetagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyString.java new file mode 100644 index 000000000000..3129cc0fba98 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_deletetagkey_string_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncDeleteTagKeyString { + + public static void main(String[] args) throws Exception { + syncDeleteTagKeyString(); + } + + public static void syncDeleteTagKeyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + String name = TagKeyName.of("[TAG_KEY]").toString(); + TagKey response = tagKeysClient.deleteTagKeyAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_deletetagkey_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyTagkeyname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyTagkeyname.java new file mode 100644 index 000000000000..821259431ca8 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/deletetagkey/SyncDeleteTagKeyTagkeyname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_deletetagkey_tagkeyname_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncDeleteTagKeyTagkeyname { + + public static void main(String[] args) throws Exception { + syncDeleteTagKeyTagkeyname(); + } + + public static void syncDeleteTagKeyTagkeyname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + TagKeyName name = TagKeyName.of("[TAG_KEY]"); + TagKey response = tagKeysClient.deleteTagKeyAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_deletetagkey_tagkeyname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/AsyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..3b2559946bad --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/AsyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(TagKeyName.of("[TAG_KEY]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = tagKeysClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_getiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..229e6ac6361b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_getiampolicy_sync] +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(TagKeyName.of("[TAG_KEY]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = tagKeysClient.getIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_getiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..a810c2dfbe46 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + Policy response = tagKeysClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_getiampolicy_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..56f160ed4e1b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/getiampolicy/SyncGetIamPolicyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_getiampolicy_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = tagKeysClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_getiampolicy_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/AsyncGetTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/AsyncGetTagKey.java new file mode 100644 index 000000000000..6ae180535b25 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/AsyncGetTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_gettagkey_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.GetTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class AsyncGetTagKey { + + public static void main(String[] args) throws Exception { + asyncGetTagKey(); + } + + public static void asyncGetTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + GetTagKeyRequest request = + GetTagKeyRequest.newBuilder().setName(TagKeyName.of("[TAG_KEY]").toString()).build(); + ApiFuture future = tagKeysClient.getTagKeyCallable().futureCall(request); + // Do something. + TagKey response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_gettagkey_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKey.java new file mode 100644 index 000000000000..b85d18a70fbc --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_gettagkey_sync] +import com.google.cloud.resourcemanager.v3.GetTagKeyRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncGetTagKey { + + public static void main(String[] args) throws Exception { + syncGetTagKey(); + } + + public static void syncGetTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + GetTagKeyRequest request = + GetTagKeyRequest.newBuilder().setName(TagKeyName.of("[TAG_KEY]").toString()).build(); + TagKey response = tagKeysClient.getTagKey(request); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_gettagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyString.java new file mode 100644 index 000000000000..081407d6a589 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_gettagkey_string_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncGetTagKeyString { + + public static void main(String[] args) throws Exception { + syncGetTagKeyString(); + } + + public static void syncGetTagKeyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + String name = TagKeyName.of("[TAG_KEY]").toString(); + TagKey response = tagKeysClient.getTagKey(name); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_gettagkey_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyTagkeyname.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyTagkeyname.java new file mode 100644 index 000000000000..af1437228c37 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/gettagkey/SyncGetTagKeyTagkeyname.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_gettagkey_tagkeyname_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncGetTagKeyTagkeyname { + + public static void main(String[] args) throws Exception { + syncGetTagKeyTagkeyname(); + } + + public static void syncGetTagKeyTagkeyname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + TagKeyName name = TagKeyName.of("[TAG_KEY]"); + TagKey response = tagKeysClient.getTagKey(name); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_gettagkey_tagkeyname_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeys.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeys.java new file mode 100644 index 000000000000..8b0168b0581b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeys.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_listtagkeys_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagKeysRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class AsyncListTagKeys { + + public static void main(String[] args) throws Exception { + asyncListTagKeys(); + } + + public static void asyncListTagKeys() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ListTagKeysRequest request = + ListTagKeysRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = tagKeysClient.listTagKeysPagedCallable().futureCall(request); + // Do something. + for (TagKey element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_listtagkeys_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeysPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeysPaged.java new file mode 100644 index 000000000000..2d98904431bc --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/AsyncListTagKeysPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_listtagkeys_paged_async] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagKeysRequest; +import com.google.cloud.resourcemanager.v3.ListTagKeysResponse; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.common.base.Strings; + +public class AsyncListTagKeysPaged { + + public static void main(String[] args) throws Exception { + asyncListTagKeysPaged(); + } + + public static void asyncListTagKeysPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ListTagKeysRequest request = + ListTagKeysRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListTagKeysResponse response = tagKeysClient.listTagKeysCallable().call(request); + for (TagKey element : response.getTagKeysList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_listtagkeys_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeys.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeys.java new file mode 100644 index 000000000000..b18ab6af6d8c --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeys.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_listtagkeys_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagKeysRequest; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncListTagKeys { + + public static void main(String[] args) throws Exception { + syncListTagKeys(); + } + + public static void syncListTagKeys() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ListTagKeysRequest request = + ListTagKeysRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (TagKey element : tagKeysClient.listTagKeys(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_listtagkeys_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysResourcename.java new file mode 100644 index 000000000000..682419db70f2 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_listtagkeys_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncListTagKeysResourcename { + + public static void main(String[] args) throws Exception { + syncListTagKeysResourcename(); + } + + public static void syncListTagKeysResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ResourceName parent = FolderName.of("[FOLDER]"); + for (TagKey element : tagKeysClient.listTagKeys(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_listtagkeys_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysString.java new file mode 100644 index 000000000000..6721f589a5ba --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/listtagkeys/SyncListTagKeysString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_listtagkeys_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; + +public class SyncListTagKeysString { + + public static void main(String[] args) throws Exception { + syncListTagKeysString(); + } + + public static void syncListTagKeysString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + String parent = FolderName.of("[FOLDER]").toString(); + for (TagKey element : tagKeysClient.listTagKeys(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_listtagkeys_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/AsyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..768556565dc3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/AsyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(TagKeyName.of("[TAG_KEY]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = tagKeysClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_setiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..90b9cc90d5c1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_setiampolicy_sync] +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(TagKeyName.of("[TAG_KEY]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = tagKeysClient.setIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_setiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..24aa5493e06b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + Policy policy = Policy.newBuilder().build(); + Policy response = tagKeysClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_setiampolicy_resourcenamepolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..b1733f17f8e5 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/setiampolicy/SyncSetIamPolicyStringPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = tagKeysClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_setiampolicy_stringpolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/AsyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..04bb7a822279 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/AsyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(TagKeyName.of("[TAG_KEY]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + tagKeysClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_testiampermissions_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..f22586257d5f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_testiampermissions_sync] +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(TagKeyName.of("[TAG_KEY]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = tagKeysClient.testIamPermissions(request); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_testiampermissions_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..0c5d6de890bc --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.TagKeyName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + ResourceName resource = TagKeyName.of("[TAG_KEY]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = tagKeysClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_testiampermissions_resourcenameliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..4b1b01dfbaae --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/testiampermissions/SyncTestIamPermissionsStringListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_testiampermissions_stringliststring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = tagKeysClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_testiampermissions_stringliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKey.java new file mode 100644 index 000000000000..72572dbdd0e3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_updatetagkey_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.cloud.resourcemanager.v3.UpdateTagKeyRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTagKey { + + public static void main(String[] args) throws Exception { + asyncUpdateTagKey(); + } + + public static void asyncUpdateTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + UpdateTagKeyRequest request = + UpdateTagKeyRequest.newBuilder() + .setTagKey(TagKey.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = tagKeysClient.updateTagKeyCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_updatetagkey_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKeyLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKeyLRO.java new file mode 100644 index 000000000000..f465fdbe2016 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/AsyncUpdateTagKeyLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_updatetagkey_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.cloud.resourcemanager.v3.UpdateTagKeyMetadata; +import com.google.cloud.resourcemanager.v3.UpdateTagKeyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTagKeyLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateTagKeyLRO(); + } + + public static void asyncUpdateTagKeyLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + UpdateTagKeyRequest request = + UpdateTagKeyRequest.newBuilder() + .setTagKey(TagKey.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + OperationFuture future = + tagKeysClient.updateTagKeyOperationCallable().futureCall(request); + // Do something. + TagKey response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_updatetagkey_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKey.java new file mode 100644 index 000000000000..e37032aa9954 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_updatetagkey_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.cloud.resourcemanager.v3.UpdateTagKeyRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTagKey { + + public static void main(String[] args) throws Exception { + syncUpdateTagKey(); + } + + public static void syncUpdateTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + UpdateTagKeyRequest request = + UpdateTagKeyRequest.newBuilder() + .setTagKey(TagKey.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + TagKey response = tagKeysClient.updateTagKeyAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_updatetagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKeyTagkeyFieldmask.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKeyTagkeyFieldmask.java new file mode 100644 index 000000000000..17076bf3ca3e --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeysclient/updatetagkey/SyncUpdateTagKeyTagkeyFieldmask.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeysclient_updatetagkey_tagkeyfieldmask_sync] +import com.google.cloud.resourcemanager.v3.TagKey; +import com.google.cloud.resourcemanager.v3.TagKeysClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTagKeyTagkeyFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateTagKeyTagkeyFieldmask(); + } + + public static void syncUpdateTagKeyTagkeyFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagKeysClient tagKeysClient = TagKeysClient.create()) { + TagKey tagKey = TagKey.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + TagKey response = tagKeysClient.updateTagKeyAsync(tagKey, updateMask).get(); + } + } +} +// [END resourcemanager_v3_generated_tagkeysclient_updatetagkey_tagkeyfieldmask_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeyssettings/gettagkey/SyncGetTagKey.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeyssettings/gettagkey/SyncGetTagKey.java new file mode 100644 index 000000000000..52771e3bd28f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagkeyssettings/gettagkey/SyncGetTagKey.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagkeyssettings_gettagkey_sync] +import com.google.cloud.resourcemanager.v3.TagKeysSettings; +import java.time.Duration; + +public class SyncGetTagKey { + + public static void main(String[] args) throws Exception { + syncGetTagKey(); + } + + public static void syncGetTagKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TagKeysSettings.Builder tagKeysSettingsBuilder = TagKeysSettings.newBuilder(); + tagKeysSettingsBuilder + .getTagKeySettings() + .setRetrySettings( + tagKeysSettingsBuilder + .getTagKeySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TagKeysSettings tagKeysSettings = tagKeysSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_tagkeyssettings_gettagkey_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..f7f8a30b5f13 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.cloud.resourcemanager.v3.TagValuesSettings; +import com.google.cloud.resourcemanager.v3.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. + TagValuesSettings tagValuesSettings = + TagValuesSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + TagValuesClient tagValuesClient = TagValuesClient.create(tagValuesSettings); + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_create_setcredentialsprovider_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider1.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..3bd70eccc8a3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetCredentialsProvider1.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_create_setcredentialsprovider1_sync] +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.cloud.resourcemanager.v3.TagValuesSettings; + +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. + TagValuesSettings tagValuesSettings = + TagValuesSettings.newBuilder() + .setTransportChannelProvider( + TagValuesSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + TagValuesClient tagValuesClient = TagValuesClient.create(tagValuesSettings); + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_create_setcredentialsprovider1_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetEndpoint.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..b2556613e5e3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/create/SyncCreateSetEndpoint.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_create_setendpoint_sync] +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.cloud.resourcemanager.v3.TagValuesSettings; +import com.google.cloud.resourcemanager.v3.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. + TagValuesSettings tagValuesSettings = + TagValuesSettings.newBuilder().setEndpoint(myEndpoint).build(); + TagValuesClient tagValuesClient = TagValuesClient.create(tagValuesSettings); + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_create_setendpoint_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValue.java new file mode 100644 index 000000000000..61c77ef9c7aa --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_createtagvalue_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.CreateTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.longrunning.Operation; + +public class AsyncCreateTagValue { + + public static void main(String[] args) throws Exception { + asyncCreateTagValue(); + } + + public static void asyncCreateTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + CreateTagValueRequest request = + CreateTagValueRequest.newBuilder() + .setTagValue(TagValue.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = tagValuesClient.createTagValueCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_createtagvalue_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValueLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValueLRO.java new file mode 100644 index 000000000000..1e02aba7095a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/AsyncCreateTagValueLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_createtagvalue_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.CreateTagValueMetadata; +import com.google.cloud.resourcemanager.v3.CreateTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class AsyncCreateTagValueLRO { + + public static void main(String[] args) throws Exception { + asyncCreateTagValueLRO(); + } + + public static void asyncCreateTagValueLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + CreateTagValueRequest request = + CreateTagValueRequest.newBuilder() + .setTagValue(TagValue.newBuilder().build()) + .setValidateOnly(true) + .build(); + OperationFuture future = + tagValuesClient.createTagValueOperationCallable().futureCall(request); + // Do something. + TagValue response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_createtagvalue_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValue.java new file mode 100644 index 000000000000..1608cb4e6c4f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_createtagvalue_sync] +import com.google.cloud.resourcemanager.v3.CreateTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncCreateTagValue { + + public static void main(String[] args) throws Exception { + syncCreateTagValue(); + } + + public static void syncCreateTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + CreateTagValueRequest request = + CreateTagValueRequest.newBuilder() + .setTagValue(TagValue.newBuilder().build()) + .setValidateOnly(true) + .build(); + TagValue response = tagValuesClient.createTagValueAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_createtagvalue_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValueTagvalue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValueTagvalue.java new file mode 100644 index 000000000000..28f0565af0c1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/createtagvalue/SyncCreateTagValueTagvalue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_createtagvalue_tagvalue_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncCreateTagValueTagvalue { + + public static void main(String[] args) throws Exception { + syncCreateTagValueTagvalue(); + } + + public static void syncCreateTagValueTagvalue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + TagValue tagValue = TagValue.newBuilder().build(); + TagValue response = tagValuesClient.createTagValueAsync(tagValue).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_createtagvalue_tagvalue_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValue.java new file mode 100644 index 000000000000..f6474b5461af --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.DeleteTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteTagValue { + + public static void main(String[] args) throws Exception { + asyncDeleteTagValue(); + } + + public static void asyncDeleteTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + DeleteTagValueRequest request = + DeleteTagValueRequest.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + ApiFuture future = tagValuesClient.deleteTagValueCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValueLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValueLRO.java new file mode 100644 index 000000000000..2832b8847251 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/AsyncDeleteTagValueLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.DeleteTagValueMetadata; +import com.google.cloud.resourcemanager.v3.DeleteTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class AsyncDeleteTagValueLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteTagValueLRO(); + } + + public static void asyncDeleteTagValueLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + DeleteTagValueRequest request = + DeleteTagValueRequest.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + OperationFuture future = + tagValuesClient.deleteTagValueOperationCallable().futureCall(request); + // Do something. + TagValue response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValue.java new file mode 100644 index 000000000000..64a4bca5b2c3 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_sync] +import com.google.cloud.resourcemanager.v3.DeleteTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncDeleteTagValue { + + public static void main(String[] args) throws Exception { + syncDeleteTagValue(); + } + + public static void syncDeleteTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + DeleteTagValueRequest request = + DeleteTagValueRequest.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + TagValue response = tagValuesClient.deleteTagValueAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueString.java new file mode 100644 index 000000000000..634b47393b76 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_string_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncDeleteTagValueString { + + public static void main(String[] args) throws Exception { + syncDeleteTagValueString(); + } + + public static void syncDeleteTagValueString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + String name = TagValueName.of("[TAG_VALUE]").toString(); + TagValue response = tagValuesClient.deleteTagValueAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueTagvaluename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueTagvaluename.java new file mode 100644 index 000000000000..8d36ca5f2bad --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/deletetagvalue/SyncDeleteTagValueTagvaluename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_tagvaluename_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncDeleteTagValueTagvaluename { + + public static void main(String[] args) throws Exception { + syncDeleteTagValueTagvaluename(); + } + + public static void syncDeleteTagValueTagvaluename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + TagValueName name = TagValueName.of("[TAG_VALUE]"); + TagValue response = tagValuesClient.deleteTagValueAsync(name).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_deletetagvalue_tagvaluename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/AsyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..600d56f3aee7 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/AsyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(TagValueName.of("[TAG_VALUE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = tagValuesClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_getiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..e1dbb54cadf1 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_getiampolicy_sync] +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(TagValueName.of("[TAG_VALUE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = tagValuesClient.getIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_getiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..d959ba85d553 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + Policy response = tagValuesClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_getiampolicy_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..b35e97004421 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/getiampolicy/SyncGetIamPolicyString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_getiampolicy_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = tagValuesClient.getIamPolicy(resource); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_getiampolicy_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/AsyncGetTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/AsyncGetTagValue.java new file mode 100644 index 000000000000..3995b6934bf8 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/AsyncGetTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_gettagvalue_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.GetTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class AsyncGetTagValue { + + public static void main(String[] args) throws Exception { + asyncGetTagValue(); + } + + public static void asyncGetTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + GetTagValueRequest request = + GetTagValueRequest.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .build(); + ApiFuture future = tagValuesClient.getTagValueCallable().futureCall(request); + // Do something. + TagValue response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_gettagvalue_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValue.java new file mode 100644 index 000000000000..fe0af953c126 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_gettagvalue_sync] +import com.google.cloud.resourcemanager.v3.GetTagValueRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncGetTagValue { + + public static void main(String[] args) throws Exception { + syncGetTagValue(); + } + + public static void syncGetTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + GetTagValueRequest request = + GetTagValueRequest.newBuilder() + .setName(TagValueName.of("[TAG_VALUE]").toString()) + .build(); + TagValue response = tagValuesClient.getTagValue(request); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_gettagvalue_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueString.java new file mode 100644 index 000000000000..39373e28501a --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_gettagvalue_string_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncGetTagValueString { + + public static void main(String[] args) throws Exception { + syncGetTagValueString(); + } + + public static void syncGetTagValueString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + String name = TagValueName.of("[TAG_VALUE]").toString(); + TagValue response = tagValuesClient.getTagValue(name); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_gettagvalue_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueTagvaluename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueTagvaluename.java new file mode 100644 index 000000000000..3aa1ca31153b --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/gettagvalue/SyncGetTagValueTagvaluename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_gettagvalue_tagvaluename_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncGetTagValueTagvaluename { + + public static void main(String[] args) throws Exception { + syncGetTagValueTagvaluename(); + } + + public static void syncGetTagValueTagvaluename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + TagValueName name = TagValueName.of("[TAG_VALUE]"); + TagValue response = tagValuesClient.getTagValue(name); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_gettagvalue_tagvaluename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValues.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValues.java new file mode 100644 index 000000000000..79aaaa4d2644 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValues.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_listtagvalues_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagValuesRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class AsyncListTagValues { + + public static void main(String[] args) throws Exception { + asyncListTagValues(); + } + + public static void asyncListTagValues() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ListTagValuesRequest request = + ListTagValuesRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = tagValuesClient.listTagValuesPagedCallable().futureCall(request); + // Do something. + for (TagValue element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_listtagvalues_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValuesPaged.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValuesPaged.java new file mode 100644 index 000000000000..e01c01e4fba6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/AsyncListTagValuesPaged.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_listtagvalues_paged_async] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagValuesRequest; +import com.google.cloud.resourcemanager.v3.ListTagValuesResponse; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.common.base.Strings; + +public class AsyncListTagValuesPaged { + + public static void main(String[] args) throws Exception { + asyncListTagValuesPaged(); + } + + public static void asyncListTagValuesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ListTagValuesRequest request = + ListTagValuesRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListTagValuesResponse response = tagValuesClient.listTagValuesCallable().call(request); + for (TagValue element : response.getTagValuesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_listtagvalues_paged_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValues.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValues.java new file mode 100644 index 000000000000..913cab8503a5 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValues.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_listtagvalues_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.ListTagValuesRequest; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncListTagValues { + + public static void main(String[] args) throws Exception { + syncListTagValues(); + } + + public static void syncListTagValues() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ListTagValuesRequest request = + ListTagValuesRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (TagValue element : tagValuesClient.listTagValues(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_listtagvalues_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesResourcename.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesResourcename.java new file mode 100644 index 000000000000..c2407fed22f4 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesResourcename.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_listtagvalues_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncListTagValuesResourcename { + + public static void main(String[] args) throws Exception { + syncListTagValuesResourcename(); + } + + public static void syncListTagValuesResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ResourceName parent = FolderName.of("[FOLDER]"); + for (TagValue element : tagValuesClient.listTagValues(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_listtagvalues_resourcename_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesString.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesString.java new file mode 100644 index 000000000000..2492e1c639bb --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/listtagvalues/SyncListTagValuesString.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_listtagvalues_string_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; + +public class SyncListTagValuesString { + + public static void main(String[] args) throws Exception { + syncListTagValuesString(); + } + + public static void syncListTagValuesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + String parent = FolderName.of("[FOLDER]").toString(); + for (TagValue element : tagValuesClient.listTagValues(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_listtagvalues_string_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/AsyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..e056032f68a0 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/AsyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(TagValueName.of("[TAG_VALUE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = tagValuesClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_setiampolicy_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..ab5027cc38a6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_setiampolicy_sync] +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(TagValueName.of("[TAG_VALUE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = tagValuesClient.setIamPolicy(request); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_setiampolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..2afd60061954 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + Policy policy = Policy.newBuilder().build(); + Policy response = tagValuesClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_setiampolicy_resourcenamepolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..89e73267af75 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/setiampolicy/SyncSetIamPolicyStringPolicy.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = tagValuesClient.setIamPolicy(resource, policy); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_setiampolicy_stringpolicy_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/AsyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..abedb9f3c50f --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/AsyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(TagValueName.of("[TAG_VALUE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + tagValuesClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_testiampermissions_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissions.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..a04b224a7758 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissions.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_testiampermissions_sync] +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(TagValueName.of("[TAG_VALUE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = tagValuesClient.testIamPermissions(request); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_testiampermissions_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..7edf87679ae9 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.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.resourcemanager.v3.samples; + +// [START +// resourcemanager_v3_generated_tagvaluesclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.resourcemanager.v3.TagValueName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + ResourceName resource = TagValueName.of("[TAG_VALUE]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + tagValuesClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_testiampermissions_resourcenameliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..a60a68b80b65 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/testiampermissions/SyncTestIamPermissionsStringListstring.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_testiampermissions_stringliststring_sync] +import com.google.cloud.resourcemanager.v3.FolderName; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + tagValuesClient.testIamPermissions(resource, permissions); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_testiampermissions_stringliststring_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValue.java new file mode 100644 index 000000000000..8b9857c42ba2 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.cloud.resourcemanager.v3.UpdateTagValueRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTagValue { + + public static void main(String[] args) throws Exception { + asyncUpdateTagValue(); + } + + public static void asyncUpdateTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + UpdateTagValueRequest request = + UpdateTagValueRequest.newBuilder() + .setTagValue(TagValue.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + ApiFuture future = tagValuesClient.updateTagValueCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValueLRO.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValueLRO.java new file mode 100644 index 000000000000..f89103a3f8f6 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/AsyncUpdateTagValueLRO.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.cloud.resourcemanager.v3.UpdateTagValueMetadata; +import com.google.cloud.resourcemanager.v3.UpdateTagValueRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTagValueLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateTagValueLRO(); + } + + public static void asyncUpdateTagValueLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + UpdateTagValueRequest request = + UpdateTagValueRequest.newBuilder() + .setTagValue(TagValue.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + OperationFuture future = + tagValuesClient.updateTagValueOperationCallable().futureCall(request); + // Do something. + TagValue response = future.get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_lro_async] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValue.java new file mode 100644 index 000000000000..3958864a29aa --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.cloud.resourcemanager.v3.UpdateTagValueRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTagValue { + + public static void main(String[] args) throws Exception { + syncUpdateTagValue(); + } + + public static void syncUpdateTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + UpdateTagValueRequest request = + UpdateTagValueRequest.newBuilder() + .setTagValue(TagValue.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setValidateOnly(true) + .build(); + TagValue response = tagValuesClient.updateTagValueAsync(request).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValueTagvalueFieldmask.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValueTagvalueFieldmask.java new file mode 100644 index 000000000000..d0182387bdea --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluesclient/updatetagvalue/SyncUpdateTagValueTagvalueFieldmask.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_tagvaluefieldmask_sync] +import com.google.cloud.resourcemanager.v3.TagValue; +import com.google.cloud.resourcemanager.v3.TagValuesClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTagValueTagvalueFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateTagValueTagvalueFieldmask(); + } + + public static void syncUpdateTagValueTagvalueFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TagValuesClient tagValuesClient = TagValuesClient.create()) { + TagValue tagValue = TagValue.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + TagValue response = tagValuesClient.updateTagValueAsync(tagValue, updateMask).get(); + } + } +} +// [END resourcemanager_v3_generated_tagvaluesclient_updatetagvalue_tagvaluefieldmask_sync] diff --git a/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluessettings/gettagvalue/SyncGetTagValue.java b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluessettings/gettagvalue/SyncGetTagValue.java new file mode 100644 index 000000000000..db6325e61652 --- /dev/null +++ b/java-resourcemanager/samples/snippets/generated/com/google/cloud/resourcemanager/v3/tagvaluessettings/gettagvalue/SyncGetTagValue.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.resourcemanager.v3.samples; + +// [START resourcemanager_v3_generated_tagvaluessettings_gettagvalue_sync] +import com.google.cloud.resourcemanager.v3.TagValuesSettings; +import java.time.Duration; + +public class SyncGetTagValue { + + public static void main(String[] args) throws Exception { + syncGetTagValue(); + } + + public static void syncGetTagValue() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TagValuesSettings.Builder tagValuesSettingsBuilder = TagValuesSettings.newBuilder(); + tagValuesSettingsBuilder + .getTagValueSettings() + .setRetrySettings( + tagValuesSettingsBuilder + .getTagValueSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TagValuesSettings tagValuesSettings = tagValuesSettingsBuilder.build(); + } +} +// [END resourcemanager_v3_generated_tagvaluessettings_gettagvalue_sync]