From abf250002ed9c3eb2404e0b76942e74cfc0750ac Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 24 Jun 2022 15:02:11 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#176) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- .../google-cloud-datastream/pom.xml | 16 + .../cloud/datastream/v1/DatastreamClient.java | 37 +- .../datastream/v1/DatastreamSettings.java | 23 +- .../datastream/v1/stub/DatastreamStub.java | 6 +- .../v1/stub/DatastreamStubSettings.java | 53 +- .../HttpJsonDatastreamCallableFactory.java | 105 + .../v1/stub/HttpJsonDatastreamStub.java | 1916 ++++++++++++ .../datastream/v1alpha1/DatastreamClient.java | 37 +- .../v1alpha1/DatastreamSettings.java | 23 +- .../v1alpha1/stub/DatastreamStub.java | 6 +- .../v1alpha1/stub/DatastreamStubSettings.java | 53 +- .../HttpJsonDatastreamCallableFactory.java | 105 + .../v1alpha1/stub/HttpJsonDatastreamStub.java | 1589 ++++++++++ .../v1/DatastreamClientHttpJsonTest.java | 2641 +++++++++++++++++ .../DatastreamClientHttpJsonTest.java | 2127 +++++++++++++ .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateConnectionProfile.java | 53 + .../AsyncCreateConnectionProfileLRO.java | 53 + .../SyncCreateConnectionProfile.java | 48 + ...leLocationnameConnectionprofileString.java | 47 + ...nProfileStringConnectionprofileString.java | 46 + .../AsyncCreatePrivateConnection.java | 51 + .../AsyncCreatePrivateConnectionLRO.java | 51 + .../SyncCreatePrivateConnection.java | 46 + ...onLocationnamePrivateconnectionString.java | 47 + ...nnectionStringPrivateconnectionString.java | 46 + .../createroute/AsyncCreateRoute.java | 52 + .../createroute/AsyncCreateRouteLRO.java | 53 + .../createroute/SyncCreateRoute.java | 48 + ...RoutePrivateconnectionnameRouteString.java | 43 + .../SyncCreateRouteStringRouteString.java | 42 + .../createstream/AsyncCreateStream.java | 52 + .../createstream/AsyncCreateStreamLRO.java | 53 + .../createstream/SyncCreateStream.java | 48 + ...cCreateStreamLocationnameStreamString.java | 41 + .../SyncCreateStreamStringStreamString.java | 41 + .../AsyncDeleteConnectionProfile.java | 50 + .../AsyncDeleteConnectionProfileLRO.java | 51 + .../SyncDeleteConnectionProfile.java | 45 + ...onnectionProfileConnectionprofilename.java | 40 + .../SyncDeleteConnectionProfileString.java | 39 + .../AsyncDeletePrivateConnection.java | 51 + .../AsyncDeletePrivateConnectionLRO.java | 52 + .../SyncDeletePrivateConnection.java | 46 + ...rivateConnectionPrivateconnectionname.java | 40 + .../SyncDeletePrivateConnectionString.java | 39 + .../deleteroute/AsyncDeleteRoute.java | 49 + .../deleteroute/AsyncDeleteRouteLRO.java | 51 + .../deleteroute/SyncDeleteRoute.java | 45 + .../deleteroute/SyncDeleteRouteRoutename.java | 38 + .../deleteroute/SyncDeleteRouteString.java | 39 + .../deletestream/AsyncDeleteStream.java | 47 + .../deletestream/AsyncDeleteStreamLRO.java | 49 + .../deletestream/SyncDeleteStream.java | 43 + .../SyncDeleteStreamStreamname.java | 38 + .../deletestream/SyncDeleteStreamString.java | 38 + .../AsyncDiscoverConnectionProfile.java | 47 + .../SyncDiscoverConnectionProfile.java | 44 + .../fetchstaticips/AsyncFetchStaticIps.java | 49 + .../AsyncFetchStaticIpsPaged.java | 57 + .../fetchstaticips/SyncFetchStaticIps.java | 46 + .../SyncFetchStaticIpsLocationname.java | 40 + .../SyncFetchStaticIpsString.java | 40 + .../AsyncGetConnectionProfile.java | 49 + .../SyncGetConnectionProfile.java | 45 + ...onnectionProfileConnectionprofilename.java | 40 + .../SyncGetConnectionProfileString.java | 40 + .../getlocation/AsyncGetLocation.java | 42 + .../getlocation/SyncGetLocation.java | 39 + .../AsyncGetPrivateConnection.java | 49 + .../SyncGetPrivateConnection.java | 45 + ...rivateConnectionPrivateconnectionname.java | 40 + .../SyncGetPrivateConnectionString.java | 40 + .../getroute/AsyncGetRoute.java | 48 + .../getroute/SyncGetRoute.java | 45 + .../getroute/SyncGetRouteRoutename.java | 39 + .../getroute/SyncGetRouteString.java | 40 + .../getstream/AsyncGetStream.java | 46 + .../getstream/SyncGetStream.java | 43 + .../getstream/SyncGetStreamStreamname.java | 39 + .../getstream/SyncGetStreamString.java | 39 + .../getstreamobject/AsyncGetStreamObject.java | 48 + .../getstreamobject/SyncGetStreamObject.java | 44 + .../SyncGetStreamObjectStreamobjectname.java | 40 + .../SyncGetStreamObjectString.java | 40 + .../AsyncListConnectionProfiles.java | 53 + .../AsyncListConnectionProfilesPaged.java | 61 + .../SyncListConnectionProfiles.java | 50 + ...yncListConnectionProfilesLocationname.java | 42 + .../SyncListConnectionProfilesString.java | 42 + .../listlocations/AsyncListLocations.java | 51 + .../AsyncListLocationsPaged.java | 58 + .../listlocations/SyncListLocations.java | 47 + .../AsyncListPrivateConnections.java | 53 + .../AsyncListPrivateConnectionsPaged.java | 61 + .../SyncListPrivateConnections.java | 50 + ...yncListPrivateConnectionsLocationname.java | 42 + .../SyncListPrivateConnectionsString.java | 42 + .../listroutes/AsyncListRoutes.java | 54 + .../listroutes/AsyncListRoutesPaged.java | 62 + .../listroutes/SyncListRoutes.java | 51 + .../SyncListRoutesPrivateconnectionname.java | 42 + .../listroutes/SyncListRoutesString.java | 42 + .../AsyncListStreamObjects.java | 51 + .../AsyncListStreamObjectsPaged.java | 59 + .../SyncListStreamObjects.java | 47 + .../SyncListStreamObjectsStreamname.java | 41 + .../SyncListStreamObjectsString.java | 41 + .../liststreams/AsyncListStreams.java | 52 + .../liststreams/AsyncListStreamsPaged.java | 60 + .../liststreams/SyncListStreams.java | 49 + .../SyncListStreamsLocationname.java | 41 + .../liststreams/SyncListStreamsString.java | 41 + .../AsyncLookupStreamObject.java | 49 + .../SyncLookupStreamObject.java | 45 + .../AsyncStartBackfillJob.java | 48 + .../SyncStartBackfillJob.java | 44 + .../SyncStartBackfillJobStreamobjectname.java | 40 + .../SyncStartBackfillJobString.java | 40 + .../stopbackfilljob/AsyncStopBackfillJob.java | 48 + .../stopbackfilljob/SyncStopBackfillJob.java | 44 + .../SyncStopBackfillJobStreamobjectname.java | 40 + .../SyncStopBackfillJobString.java | 40 + .../AsyncUpdateConnectionProfile.java | 52 + .../AsyncUpdateConnectionProfileLRO.java | 52 + .../SyncUpdateConnectionProfile.java | 47 + ...tionProfileConnectionprofileFieldmask.java | 43 + .../updatestream/AsyncUpdateStream.java | 51 + .../updatestream/AsyncUpdateStreamLRO.java | 52 + .../updatestream/SyncUpdateStream.java | 47 + .../SyncUpdateStreamStreamFieldmask.java | 40 + .../SyncGetConnectionProfile.java | 45 + .../SyncGetConnectionProfile.java | 45 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../AsyncCreateConnectionProfile.java | 51 + .../AsyncCreateConnectionProfileLRO.java | 51 + .../SyncCreateConnectionProfile.java | 46 + ...leLocationnameConnectionprofileString.java | 47 + ...nProfileStringConnectionprofileString.java | 46 + .../AsyncCreatePrivateConnection.java | 51 + .../AsyncCreatePrivateConnectionLRO.java | 51 + .../SyncCreatePrivateConnection.java | 46 + ...onLocationnamePrivateconnectionString.java | 47 + ...nnectionStringPrivateconnectionString.java | 46 + .../createroute/AsyncCreateRoute.java | 52 + .../createroute/AsyncCreateRouteLRO.java | 53 + .../createroute/SyncCreateRoute.java | 48 + ...RoutePrivateconnectionnameRouteString.java | 44 + .../SyncCreateRouteStringRouteString.java | 42 + .../createstream/AsyncCreateStream.java | 52 + .../createstream/AsyncCreateStreamLRO.java | 53 + .../createstream/SyncCreateStream.java | 48 + ...cCreateStreamLocationnameStreamString.java | 41 + .../SyncCreateStreamStringStreamString.java | 41 + .../AsyncDeleteConnectionProfile.java | 50 + .../AsyncDeleteConnectionProfileLRO.java | 51 + .../SyncDeleteConnectionProfile.java | 45 + ...onnectionProfileConnectionprofilename.java | 41 + .../SyncDeleteConnectionProfileString.java | 39 + .../AsyncDeletePrivateConnection.java | 51 + .../AsyncDeletePrivateConnectionLRO.java | 52 + .../SyncDeletePrivateConnection.java | 46 + ...rivateConnectionPrivateconnectionname.java | 41 + .../SyncDeletePrivateConnectionString.java | 39 + .../deleteroute/AsyncDeleteRoute.java | 49 + .../deleteroute/AsyncDeleteRouteLRO.java | 51 + .../deleteroute/SyncDeleteRoute.java | 45 + .../deleteroute/SyncDeleteRouteRoutename.java | 38 + .../deleteroute/SyncDeleteRouteString.java | 39 + .../deletestream/AsyncDeleteStream.java | 47 + .../deletestream/AsyncDeleteStreamLRO.java | 49 + .../deletestream/SyncDeleteStream.java | 43 + .../SyncDeleteStreamStreamname.java | 38 + .../deletestream/SyncDeleteStreamString.java | 38 + .../AsyncDiscoverConnectionProfile.java | 47 + .../SyncDiscoverConnectionProfile.java | 44 + .../fetcherrors/AsyncFetchErrors.java | 46 + .../fetcherrors/AsyncFetchErrorsLRO.java | 48 + .../fetcherrors/SyncFetchErrors.java | 43 + .../fetchstaticips/AsyncFetchStaticIps.java | 49 + .../AsyncFetchStaticIpsPaged.java | 57 + .../fetchstaticips/SyncFetchStaticIps.java | 46 + .../SyncFetchStaticIpsLocationname.java | 40 + .../SyncFetchStaticIpsString.java | 40 + .../AsyncGetConnectionProfile.java | 49 + .../SyncGetConnectionProfile.java | 45 + ...onnectionProfileConnectionprofilename.java | 42 + .../SyncGetConnectionProfileString.java | 40 + .../AsyncGetPrivateConnection.java | 49 + .../SyncGetPrivateConnection.java | 45 + ...rivateConnectionPrivateconnectionname.java | 42 + .../SyncGetPrivateConnectionString.java | 40 + .../getroute/AsyncGetRoute.java | 48 + .../getroute/SyncGetRoute.java | 45 + .../getroute/SyncGetRouteRoutename.java | 39 + .../getroute/SyncGetRouteString.java | 40 + .../getstream/AsyncGetStream.java | 46 + .../getstream/SyncGetStream.java | 43 + .../getstream/SyncGetStreamStreamname.java | 39 + .../getstream/SyncGetStreamString.java | 39 + .../AsyncListConnectionProfiles.java | 53 + .../AsyncListConnectionProfilesPaged.java | 61 + .../SyncListConnectionProfiles.java | 50 + ...yncListConnectionProfilesLocationname.java | 42 + .../SyncListConnectionProfilesString.java | 42 + .../AsyncListPrivateConnections.java | 53 + .../AsyncListPrivateConnectionsPaged.java | 61 + .../SyncListPrivateConnections.java | 50 + ...yncListPrivateConnectionsLocationname.java | 42 + .../SyncListPrivateConnectionsString.java | 42 + .../listroutes/AsyncListRoutes.java | 54 + .../listroutes/AsyncListRoutesPaged.java | 62 + .../listroutes/SyncListRoutes.java | 51 + .../SyncListRoutesPrivateconnectionname.java | 42 + .../listroutes/SyncListRoutesString.java | 42 + .../liststreams/AsyncListStreams.java | 52 + .../liststreams/AsyncListStreamsPaged.java | 60 + .../liststreams/SyncListStreams.java | 49 + .../SyncListStreamsLocationname.java | 41 + .../liststreams/SyncListStreamsString.java | 41 + .../AsyncUpdateConnectionProfile.java | 50 + .../AsyncUpdateConnectionProfileLRO.java | 50 + .../SyncUpdateConnectionProfile.java | 45 + ...tionProfileConnectionprofileFieldmask.java | 43 + .../updatestream/AsyncUpdateStream.java | 51 + .../updatestream/AsyncUpdateStreamLRO.java | 52 + .../updatestream/SyncUpdateStream.java | 47 + .../SyncUpdateStreamStreamFieldmask.java | 40 + .../SyncGetConnectionProfile.java | 45 + .../SyncGetConnectionProfile.java | 45 + 234 files changed, 18821 insertions(+), 22 deletions(-) create mode 100644 java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamCallableFactory.java create mode 100644 java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamStub.java create mode 100644 java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamCallableFactory.java create mode 100644 java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamStub.java create mode 100644 java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1/DatastreamClientHttpJsonTest.java create mode 100644 java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1alpha1/DatastreamClientHttpJsonTest.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetEndpoint.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRouteLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRouteStringRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStreamLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamStringStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStreamLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamStreamname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIps.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/AsyncGetLocation.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/SyncGetLocation.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/AsyncGetRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteRoutename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/AsyncGetStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamStreamname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/AsyncGetStreamObject.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObject.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectStreamobjectname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocations.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocationsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/SyncListLocations.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnections.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutes.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutesPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutes.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjects.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjectsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjects.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsStreamname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreams.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreamsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreams.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/AsyncLookupStreamObject.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/SyncLookupStreamObject.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/AsyncStartBackfillJob.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJob.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobStreamobjectname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/AsyncStopBackfillJob.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJob.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobStreamobjectname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetEndpoint.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRouteLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRouteStringRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStreamLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamStringStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStreamLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamStreamname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrors.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrorsLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/SyncFetchErrors.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIps.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/AsyncGetRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRoute.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteRoutename.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/AsyncGetStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamStreamname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnections.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutes.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutesPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutes.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreams.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreamsPaged.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreams.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsLocationname.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsString.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStream.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.java create mode 100644 java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.java diff --git a/java-datastream/google-cloud-datastream/pom.xml b/java-datastream/google-cloud-datastream/pom.xml index f0aa8c07103e..9c8a11c59d78 100644 --- a/java-datastream/google-cloud-datastream/pom.xml +++ b/java-datastream/google-cloud-datastream/pom.xml @@ -64,6 +64,10 @@ com.google.api gax-grpc + + + com.google.api + gax-httpjson org.threeten @@ -89,12 +93,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamClient.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamClient.java index c3ffc32c01b2..b2ea9b78bab0 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamClient.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamClient.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; @@ -34,7 +35,6 @@ import com.google.cloud.location.Location; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -107,13 +107,28 @@ * DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); * } * + *

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.
+ * DatastreamSettings datastreamSettings =
+ *     DatastreamSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DatastreamSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class DatastreamClient implements BackgroundResource { private final DatastreamSettings settings; private final DatastreamStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DatastreamClient with default settings. */ public static final DatastreamClient create() throws IOException { @@ -143,13 +158,17 @@ public static final DatastreamClient create(DatastreamStub stub) { protected DatastreamClient(DatastreamSettings settings) throws IOException { this.settings = settings; this.stub = ((DatastreamStubSettings) 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 DatastreamClient(DatastreamStub 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 DatastreamSettings getSettings() { @@ -164,10 +183,18 @@ public DatastreamStub 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. /** * Use this method to list connection profiles created in a project and location. diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamSettings.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamSettings.java index 88c71dabad45..c300817a0647 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamSettings.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/DatastreamSettings.java @@ -29,6 +29,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; @@ -327,11 +328,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DatastreamStubSettings.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 DatastreamStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DatastreamStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DatastreamStubSettings.defaultTransportChannelProvider(); } @@ -341,11 +349,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DatastreamStubSettings.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); @@ -383,6 +397,11 @@ private static Builder createDefault() { return new Builder(DatastreamStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DatastreamStubSettings.newHttpJsonBuilder()); + } + public DatastreamStubSettings.Builder getStubSettingsBuilder() { return ((DatastreamStubSettings.Builder) getStubSettings()); } diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStub.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStub.java index 8104da66cf7b..b86ed104ebfc 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStub.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStub.java @@ -86,7 +86,11 @@ public abstract class DatastreamStub 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-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStubSettings.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStubSettings.java index 3598bbd268c5..6114d9a92798 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStubSettings.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/DatastreamStubSettings.java @@ -34,6 +34,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; @@ -863,6 +866,11 @@ public DatastreamStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDatastreamStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDatastreamStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -895,18 +903,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(DatastreamStubSettings.class)) @@ -914,11 +929,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(DatastreamStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DatastreamStubSettings.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); @@ -1272,6 +1306,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 .listConnectionProfilesSettings() diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamCallableFactory.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamCallableFactory.java new file mode 100644 index 000000000000..bdb126e8e890 --- /dev/null +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamCallableFactory.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.datastream.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Datastream service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDatastreamCallableFactory + 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-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamStub.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamStub.java new file mode 100644 index 000000000000..93b28d2ef06c --- /dev/null +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1/stub/HttpJsonDatastreamStub.java @@ -0,0 +1,1916 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.stub; + +import static com.google.cloud.datastream.v1.DatastreamClient.FetchStaticIpsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListConnectionProfilesPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListLocationsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListPrivateConnectionsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListRoutesPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListStreamObjectsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListStreamsPagedResponse; + +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.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1.CreateRouteRequest; +import com.google.cloud.datastream.v1.CreateStreamRequest; +import com.google.cloud.datastream.v1.DeleteConnectionProfileRequest; +import com.google.cloud.datastream.v1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1.DeleteRouteRequest; +import com.google.cloud.datastream.v1.DeleteStreamRequest; +import com.google.cloud.datastream.v1.DiscoverConnectionProfileRequest; +import com.google.cloud.datastream.v1.DiscoverConnectionProfileResponse; +import com.google.cloud.datastream.v1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1.FetchStaticIpsResponse; +import com.google.cloud.datastream.v1.GetConnectionProfileRequest; +import com.google.cloud.datastream.v1.GetPrivateConnectionRequest; +import com.google.cloud.datastream.v1.GetRouteRequest; +import com.google.cloud.datastream.v1.GetStreamObjectRequest; +import com.google.cloud.datastream.v1.GetStreamRequest; +import com.google.cloud.datastream.v1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1.ListConnectionProfilesResponse; +import com.google.cloud.datastream.v1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1.ListPrivateConnectionsResponse; +import com.google.cloud.datastream.v1.ListRoutesRequest; +import com.google.cloud.datastream.v1.ListRoutesResponse; +import com.google.cloud.datastream.v1.ListStreamObjectsRequest; +import com.google.cloud.datastream.v1.ListStreamObjectsResponse; +import com.google.cloud.datastream.v1.ListStreamsRequest; +import com.google.cloud.datastream.v1.ListStreamsResponse; +import com.google.cloud.datastream.v1.LookupStreamObjectRequest; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.cloud.datastream.v1.Route; +import com.google.cloud.datastream.v1.StartBackfillJobRequest; +import com.google.cloud.datastream.v1.StartBackfillJobResponse; +import com.google.cloud.datastream.v1.StopBackfillJobRequest; +import com.google.cloud.datastream.v1.StopBackfillJobResponse; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.StreamObject; +import com.google.cloud.datastream.v1.UpdateConnectionProfileRequest; +import com.google.cloud.datastream.v1.UpdateStreamRequest; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +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 Datastream service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDatastreamStub extends DatastreamStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(ConnectionProfile.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Route.getDescriptor()) + .add(PrivateConnection.getDescriptor()) + .add(Stream.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListConnectionProfilesRequest, ListConnectionProfilesResponse> + listConnectionProfilesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/ListConnectionProfiles") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/connectionProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConnectionProfilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/GetConnectionProfile") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/connectionProfiles/*}", + 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(ConnectionProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/CreateConnectionProfile") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/connectionProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "connectionProfileId", request.getConnectionProfileId()); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("connectionProfile", request.getConnectionProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConnectionProfileRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/UpdateConnectionProfile") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{connectionProfile.name=projects/*/locations/*/connectionProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "connectionProfile.name", + request.getConnectionProfile().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("connectionProfile", request.getConnectionProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateConnectionProfileRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/DeleteConnectionProfile") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/connectionProfiles/*}", + 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, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteConnectionProfileRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + DiscoverConnectionProfileRequest, DiscoverConnectionProfileResponse> + discoverConnectionProfileMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/DiscoverConnectionProfile") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/connectionProfiles:discover", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DiscoverConnectionProfileResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listStreamsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/ListStreams") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/streams", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListStreamsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/GetStream") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/streams/*}", + 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(Stream.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/CreateStream") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/streams", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "streamId", request.getStreamId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("stream", request.getStream())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateStreamRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/UpdateStream") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{stream.name=projects/*/locations/*/streams/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "stream.name", request.getStream().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("stream", request.getStream())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateStreamRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/DeleteStream") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/streams/*}", + 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, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteStreamRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getStreamObjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/GetStreamObject") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/streams/*/objects/*}", + 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(StreamObject.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + lookupStreamObjectMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/LookupStreamObject") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/streams/*}/objects:lookup", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(StreamObject.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listStreamObjectsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/ListStreamObjects") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/streams/*}/objects", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListStreamObjectsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + startBackfillJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/StartBackfillJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{object=projects/*/locations/*/streams/*/objects/*}:startBackfillJob", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "object", request.getObject()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearObject().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(StartBackfillJobResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + stopBackfillJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/StopBackfillJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{object=projects/*/locations/*/streams/*/objects/*}:stopBackfillJob", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "object", request.getObject()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearObject().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(StopBackfillJobResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + fetchStaticIpsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/FetchStaticIps") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*}:fetchStaticIps", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FetchStaticIpsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createPrivateConnectionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/CreatePrivateConnection") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/privateConnections", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "privateConnectionId", request.getPrivateConnectionId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("privateConnection", request.getPrivateConnection())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreatePrivateConnectionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getPrivateConnectionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/GetPrivateConnection") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/privateConnections/*}", + 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(PrivateConnection.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListPrivateConnectionsRequest, ListPrivateConnectionsResponse> + listPrivateConnectionsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/ListPrivateConnections") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/privateConnections", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListPrivateConnectionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deletePrivateConnectionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/DeletePrivateConnection") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/privateConnections/*}", + 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, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeletePrivateConnectionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createRouteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/CreateRoute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/privateConnections/*}/routes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "routeId", request.getRouteId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("route", request.getRoute())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateRouteRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getRouteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/GetRoute") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/privateConnections/*/routes/*}", + 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(Route.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listRoutesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/ListRoutes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/privateConnections/*}/routes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListRoutesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteRouteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1.Datastream/DeleteRoute") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/privateConnections/*/routes/*}", + 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, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteRouteRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listLocationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*}/locations", + 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(ListLocationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getLocationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*}", + 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(Location.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listConnectionProfilesCallable; + private final UnaryCallable + listConnectionProfilesPagedCallable; + private final UnaryCallable + getConnectionProfileCallable; + private final UnaryCallable + createConnectionProfileCallable; + private final OperationCallable< + CreateConnectionProfileRequest, ConnectionProfile, OperationMetadata> + createConnectionProfileOperationCallable; + private final UnaryCallable + updateConnectionProfileCallable; + private final OperationCallable< + UpdateConnectionProfileRequest, ConnectionProfile, OperationMetadata> + updateConnectionProfileOperationCallable; + private final UnaryCallable + deleteConnectionProfileCallable; + private final OperationCallable + deleteConnectionProfileOperationCallable; + private final UnaryCallable + discoverConnectionProfileCallable; + private final UnaryCallable listStreamsCallable; + private final UnaryCallable + listStreamsPagedCallable; + private final UnaryCallable getStreamCallable; + private final UnaryCallable createStreamCallable; + private final OperationCallable + createStreamOperationCallable; + private final UnaryCallable updateStreamCallable; + private final OperationCallable + updateStreamOperationCallable; + private final UnaryCallable deleteStreamCallable; + private final OperationCallable + deleteStreamOperationCallable; + private final UnaryCallable getStreamObjectCallable; + private final UnaryCallable lookupStreamObjectCallable; + private final UnaryCallable + listStreamObjectsCallable; + private final UnaryCallable + listStreamObjectsPagedCallable; + private final UnaryCallable + startBackfillJobCallable; + private final UnaryCallable + stopBackfillJobCallable; + private final UnaryCallable fetchStaticIpsCallable; + private final UnaryCallable + fetchStaticIpsPagedCallable; + private final UnaryCallable + createPrivateConnectionCallable; + private final OperationCallable< + CreatePrivateConnectionRequest, PrivateConnection, OperationMetadata> + createPrivateConnectionOperationCallable; + private final UnaryCallable + getPrivateConnectionCallable; + private final UnaryCallable + listPrivateConnectionsCallable; + private final UnaryCallable + listPrivateConnectionsPagedCallable; + private final UnaryCallable + deletePrivateConnectionCallable; + private final OperationCallable + deletePrivateConnectionOperationCallable; + private final UnaryCallable createRouteCallable; + private final OperationCallable + createRouteOperationCallable; + private final UnaryCallable getRouteCallable; + private final UnaryCallable listRoutesCallable; + private final UnaryCallable listRoutesPagedCallable; + private final UnaryCallable deleteRouteCallable; + private final OperationCallable + deleteRouteOperationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDatastreamStub create(DatastreamStubSettings settings) + throws IOException { + return new HttpJsonDatastreamStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDatastreamStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDatastreamStub( + DatastreamStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDatastreamStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDatastreamStub( + DatastreamStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDatastreamStub, 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 HttpJsonDatastreamStub(DatastreamStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDatastreamCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDatastreamStub, 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 HttpJsonDatastreamStub( + DatastreamStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listConnectionProfilesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConnectionProfilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + discoverConnectionProfileTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(discoverConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listStreamsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listStreamsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getStreamObjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getStreamObjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + lookupStreamObjectTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(lookupStreamObjectMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listStreamObjectsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listStreamObjectsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + startBackfillJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(startBackfillJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + stopBackfillJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(stopBackfillJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + fetchStaticIpsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(fetchStaticIpsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createPrivateConnectionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createPrivateConnectionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getPrivateConnectionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPrivateConnectionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listPrivateConnectionsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listPrivateConnectionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deletePrivateConnectionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePrivateConnectionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createRouteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createRouteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getRouteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRouteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listRoutesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listRoutesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteRouteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteRouteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listLocationsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getLocationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listConnectionProfilesCallable = + callableFactory.createUnaryCallable( + listConnectionProfilesTransportSettings, + settings.listConnectionProfilesSettings(), + clientContext); + this.listConnectionProfilesPagedCallable = + callableFactory.createPagedCallable( + listConnectionProfilesTransportSettings, + settings.listConnectionProfilesSettings(), + clientContext); + this.getConnectionProfileCallable = + callableFactory.createUnaryCallable( + getConnectionProfileTransportSettings, + settings.getConnectionProfileSettings(), + clientContext); + this.createConnectionProfileCallable = + callableFactory.createUnaryCallable( + createConnectionProfileTransportSettings, + settings.createConnectionProfileSettings(), + clientContext); + this.createConnectionProfileOperationCallable = + callableFactory.createOperationCallable( + createConnectionProfileTransportSettings, + settings.createConnectionProfileOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateConnectionProfileCallable = + callableFactory.createUnaryCallable( + updateConnectionProfileTransportSettings, + settings.updateConnectionProfileSettings(), + clientContext); + this.updateConnectionProfileOperationCallable = + callableFactory.createOperationCallable( + updateConnectionProfileTransportSettings, + settings.updateConnectionProfileOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteConnectionProfileCallable = + callableFactory.createUnaryCallable( + deleteConnectionProfileTransportSettings, + settings.deleteConnectionProfileSettings(), + clientContext); + this.deleteConnectionProfileOperationCallable = + callableFactory.createOperationCallable( + deleteConnectionProfileTransportSettings, + settings.deleteConnectionProfileOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.discoverConnectionProfileCallable = + callableFactory.createUnaryCallable( + discoverConnectionProfileTransportSettings, + settings.discoverConnectionProfileSettings(), + clientContext); + this.listStreamsCallable = + callableFactory.createUnaryCallable( + listStreamsTransportSettings, settings.listStreamsSettings(), clientContext); + this.listStreamsPagedCallable = + callableFactory.createPagedCallable( + listStreamsTransportSettings, settings.listStreamsSettings(), clientContext); + this.getStreamCallable = + callableFactory.createUnaryCallable( + getStreamTransportSettings, settings.getStreamSettings(), clientContext); + this.createStreamCallable = + callableFactory.createUnaryCallable( + createStreamTransportSettings, settings.createStreamSettings(), clientContext); + this.createStreamOperationCallable = + callableFactory.createOperationCallable( + createStreamTransportSettings, + settings.createStreamOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateStreamCallable = + callableFactory.createUnaryCallable( + updateStreamTransportSettings, settings.updateStreamSettings(), clientContext); + this.updateStreamOperationCallable = + callableFactory.createOperationCallable( + updateStreamTransportSettings, + settings.updateStreamOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteStreamCallable = + callableFactory.createUnaryCallable( + deleteStreamTransportSettings, settings.deleteStreamSettings(), clientContext); + this.deleteStreamOperationCallable = + callableFactory.createOperationCallable( + deleteStreamTransportSettings, + settings.deleteStreamOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getStreamObjectCallable = + callableFactory.createUnaryCallable( + getStreamObjectTransportSettings, settings.getStreamObjectSettings(), clientContext); + this.lookupStreamObjectCallable = + callableFactory.createUnaryCallable( + lookupStreamObjectTransportSettings, + settings.lookupStreamObjectSettings(), + clientContext); + this.listStreamObjectsCallable = + callableFactory.createUnaryCallable( + listStreamObjectsTransportSettings, + settings.listStreamObjectsSettings(), + clientContext); + this.listStreamObjectsPagedCallable = + callableFactory.createPagedCallable( + listStreamObjectsTransportSettings, + settings.listStreamObjectsSettings(), + clientContext); + this.startBackfillJobCallable = + callableFactory.createUnaryCallable( + startBackfillJobTransportSettings, settings.startBackfillJobSettings(), clientContext); + this.stopBackfillJobCallable = + callableFactory.createUnaryCallable( + stopBackfillJobTransportSettings, settings.stopBackfillJobSettings(), clientContext); + this.fetchStaticIpsCallable = + callableFactory.createUnaryCallable( + fetchStaticIpsTransportSettings, settings.fetchStaticIpsSettings(), clientContext); + this.fetchStaticIpsPagedCallable = + callableFactory.createPagedCallable( + fetchStaticIpsTransportSettings, settings.fetchStaticIpsSettings(), clientContext); + this.createPrivateConnectionCallable = + callableFactory.createUnaryCallable( + createPrivateConnectionTransportSettings, + settings.createPrivateConnectionSettings(), + clientContext); + this.createPrivateConnectionOperationCallable = + callableFactory.createOperationCallable( + createPrivateConnectionTransportSettings, + settings.createPrivateConnectionOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getPrivateConnectionCallable = + callableFactory.createUnaryCallable( + getPrivateConnectionTransportSettings, + settings.getPrivateConnectionSettings(), + clientContext); + this.listPrivateConnectionsCallable = + callableFactory.createUnaryCallable( + listPrivateConnectionsTransportSettings, + settings.listPrivateConnectionsSettings(), + clientContext); + this.listPrivateConnectionsPagedCallable = + callableFactory.createPagedCallable( + listPrivateConnectionsTransportSettings, + settings.listPrivateConnectionsSettings(), + clientContext); + this.deletePrivateConnectionCallable = + callableFactory.createUnaryCallable( + deletePrivateConnectionTransportSettings, + settings.deletePrivateConnectionSettings(), + clientContext); + this.deletePrivateConnectionOperationCallable = + callableFactory.createOperationCallable( + deletePrivateConnectionTransportSettings, + settings.deletePrivateConnectionOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createRouteCallable = + callableFactory.createUnaryCallable( + createRouteTransportSettings, settings.createRouteSettings(), clientContext); + this.createRouteOperationCallable = + callableFactory.createOperationCallable( + createRouteTransportSettings, + settings.createRouteOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getRouteCallable = + callableFactory.createUnaryCallable( + getRouteTransportSettings, settings.getRouteSettings(), clientContext); + this.listRoutesCallable = + callableFactory.createUnaryCallable( + listRoutesTransportSettings, settings.listRoutesSettings(), clientContext); + this.listRoutesPagedCallable = + callableFactory.createPagedCallable( + listRoutesTransportSettings, settings.listRoutesSettings(), clientContext); + this.deleteRouteCallable = + callableFactory.createUnaryCallable( + deleteRouteTransportSettings, settings.deleteRouteSettings(), clientContext); + this.deleteRouteOperationCallable = + callableFactory.createOperationCallable( + deleteRouteTransportSettings, + settings.deleteRouteOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listConnectionProfilesMethodDescriptor); + methodDescriptors.add(getConnectionProfileMethodDescriptor); + methodDescriptors.add(createConnectionProfileMethodDescriptor); + methodDescriptors.add(updateConnectionProfileMethodDescriptor); + methodDescriptors.add(deleteConnectionProfileMethodDescriptor); + methodDescriptors.add(discoverConnectionProfileMethodDescriptor); + methodDescriptors.add(listStreamsMethodDescriptor); + methodDescriptors.add(getStreamMethodDescriptor); + methodDescriptors.add(createStreamMethodDescriptor); + methodDescriptors.add(updateStreamMethodDescriptor); + methodDescriptors.add(deleteStreamMethodDescriptor); + methodDescriptors.add(getStreamObjectMethodDescriptor); + methodDescriptors.add(lookupStreamObjectMethodDescriptor); + methodDescriptors.add(listStreamObjectsMethodDescriptor); + methodDescriptors.add(startBackfillJobMethodDescriptor); + methodDescriptors.add(stopBackfillJobMethodDescriptor); + methodDescriptors.add(fetchStaticIpsMethodDescriptor); + methodDescriptors.add(createPrivateConnectionMethodDescriptor); + methodDescriptors.add(getPrivateConnectionMethodDescriptor); + methodDescriptors.add(listPrivateConnectionsMethodDescriptor); + methodDescriptors.add(deletePrivateConnectionMethodDescriptor); + methodDescriptors.add(createRouteMethodDescriptor); + methodDescriptors.add(getRouteMethodDescriptor); + methodDescriptors.add(listRoutesMethodDescriptor); + methodDescriptors.add(deleteRouteMethodDescriptor); + methodDescriptors.add(listLocationsMethodDescriptor); + methodDescriptors.add(getLocationMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listConnectionProfilesCallable() { + return listConnectionProfilesCallable; + } + + @Override + public UnaryCallable + listConnectionProfilesPagedCallable() { + return listConnectionProfilesPagedCallable; + } + + @Override + public UnaryCallable + getConnectionProfileCallable() { + return getConnectionProfileCallable; + } + + @Override + public UnaryCallable + createConnectionProfileCallable() { + return createConnectionProfileCallable; + } + + @Override + public OperationCallable + createConnectionProfileOperationCallable() { + return createConnectionProfileOperationCallable; + } + + @Override + public UnaryCallable + updateConnectionProfileCallable() { + return updateConnectionProfileCallable; + } + + @Override + public OperationCallable + updateConnectionProfileOperationCallable() { + return updateConnectionProfileOperationCallable; + } + + @Override + public UnaryCallable + deleteConnectionProfileCallable() { + return deleteConnectionProfileCallable; + } + + @Override + public OperationCallable + deleteConnectionProfileOperationCallable() { + return deleteConnectionProfileOperationCallable; + } + + @Override + public UnaryCallable + discoverConnectionProfileCallable() { + return discoverConnectionProfileCallable; + } + + @Override + public UnaryCallable listStreamsCallable() { + return listStreamsCallable; + } + + @Override + public UnaryCallable listStreamsPagedCallable() { + return listStreamsPagedCallable; + } + + @Override + public UnaryCallable getStreamCallable() { + return getStreamCallable; + } + + @Override + public UnaryCallable createStreamCallable() { + return createStreamCallable; + } + + @Override + public OperationCallable + createStreamOperationCallable() { + return createStreamOperationCallable; + } + + @Override + public UnaryCallable updateStreamCallable() { + return updateStreamCallable; + } + + @Override + public OperationCallable + updateStreamOperationCallable() { + return updateStreamOperationCallable; + } + + @Override + public UnaryCallable deleteStreamCallable() { + return deleteStreamCallable; + } + + @Override + public OperationCallable + deleteStreamOperationCallable() { + return deleteStreamOperationCallable; + } + + @Override + public UnaryCallable getStreamObjectCallable() { + return getStreamObjectCallable; + } + + @Override + public UnaryCallable lookupStreamObjectCallable() { + return lookupStreamObjectCallable; + } + + @Override + public UnaryCallable + listStreamObjectsCallable() { + return listStreamObjectsCallable; + } + + @Override + public UnaryCallable + listStreamObjectsPagedCallable() { + return listStreamObjectsPagedCallable; + } + + @Override + public UnaryCallable + startBackfillJobCallable() { + return startBackfillJobCallable; + } + + @Override + public UnaryCallable stopBackfillJobCallable() { + return stopBackfillJobCallable; + } + + @Override + public UnaryCallable fetchStaticIpsCallable() { + return fetchStaticIpsCallable; + } + + @Override + public UnaryCallable + fetchStaticIpsPagedCallable() { + return fetchStaticIpsPagedCallable; + } + + @Override + public UnaryCallable + createPrivateConnectionCallable() { + return createPrivateConnectionCallable; + } + + @Override + public OperationCallable + createPrivateConnectionOperationCallable() { + return createPrivateConnectionOperationCallable; + } + + @Override + public UnaryCallable + getPrivateConnectionCallable() { + return getPrivateConnectionCallable; + } + + @Override + public UnaryCallable + listPrivateConnectionsCallable() { + return listPrivateConnectionsCallable; + } + + @Override + public UnaryCallable + listPrivateConnectionsPagedCallable() { + return listPrivateConnectionsPagedCallable; + } + + @Override + public UnaryCallable + deletePrivateConnectionCallable() { + return deletePrivateConnectionCallable; + } + + @Override + public OperationCallable + deletePrivateConnectionOperationCallable() { + return deletePrivateConnectionOperationCallable; + } + + @Override + public UnaryCallable createRouteCallable() { + return createRouteCallable; + } + + @Override + public OperationCallable + createRouteOperationCallable() { + return createRouteOperationCallable; + } + + @Override + public UnaryCallable getRouteCallable() { + return getRouteCallable; + } + + @Override + public UnaryCallable listRoutesCallable() { + return listRoutesCallable; + } + + @Override + public UnaryCallable listRoutesPagedCallable() { + return listRoutesPagedCallable; + } + + @Override + public UnaryCallable deleteRouteCallable() { + return deleteRouteCallable; + } + + @Override + public OperationCallable + deleteRouteOperationCallable() { + return deleteRouteOperationCallable; + } + + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @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-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamClient.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamClient.java index 8e0177397e8e..ccfa9694c26a 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamClient.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.datastream.v1alpha1.stub.DatastreamStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -104,6 +104,20 @@ * DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); * } * + *

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.
+ * DatastreamSettings datastreamSettings =
+ *     DatastreamSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DatastreamSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -111,7 +125,8 @@ public class DatastreamClient implements BackgroundResource { private final DatastreamSettings settings; private final DatastreamStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DatastreamClient with default settings. */ public static final DatastreamClient create() throws IOException { @@ -141,13 +156,17 @@ public static final DatastreamClient create(DatastreamStub stub) { protected DatastreamClient(DatastreamSettings settings) throws IOException { this.settings = settings; this.stub = ((DatastreamStubSettings) 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 DatastreamClient(DatastreamStub 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 DatastreamSettings getSettings() { @@ -162,10 +181,18 @@ public DatastreamStub 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. /** * Use this method to list connection profiles created in a project and location. diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamSettings.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamSettings.java index 69e7b137c5b1..bd0a8f98380a 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamSettings.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/DatastreamSettings.java @@ -27,6 +27,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -293,11 +294,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DatastreamStubSettings.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 DatastreamStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DatastreamStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DatastreamStubSettings.defaultTransportChannelProvider(); } @@ -307,11 +315,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DatastreamStubSettings.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); @@ -349,6 +363,11 @@ private static Builder createDefault() { return new Builder(DatastreamStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DatastreamStubSettings.newHttpJsonBuilder()); + } + public DatastreamStubSettings.Builder getStubSettingsBuilder() { return ((DatastreamStubSettings.Builder) getStubSettings()); } diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStub.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStub.java index 4fb8dac5b6bf..d95856b80aaa 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStub.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStub.java @@ -75,7 +75,11 @@ public abstract class DatastreamStub 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-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStubSettings.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStubSettings.java index 1620f180898c..09435df80be3 100644 --- a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStubSettings.java +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/DatastreamStubSettings.java @@ -32,6 +32,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -697,6 +700,11 @@ public DatastreamStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDatastreamStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDatastreamStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -729,18 +737,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(DatastreamStubSettings.class)) @@ -748,11 +763,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(DatastreamStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DatastreamStubSettings.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); @@ -1068,6 +1102,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 .listConnectionProfilesSettings() diff --git a/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamCallableFactory.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamCallableFactory.java new file mode 100644 index 000000000000..b4cfafb15046 --- /dev/null +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamCallableFactory.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.datastream.v1alpha1.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 Datastream service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDatastreamCallableFactory + 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-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamStub.java b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamStub.java new file mode 100644 index 000000000000..3a1a643d2175 --- /dev/null +++ b/java-datastream/google-cloud-datastream/src/main/java/com/google/cloud/datastream/v1alpha1/stub/HttpJsonDatastreamStub.java @@ -0,0 +1,1589 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.stub; + +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.FetchStaticIpsPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListConnectionProfilesPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListPrivateConnectionsPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListRoutesPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListStreamsPagedResponse; + +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.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.CreateRouteRequest; +import com.google.cloud.datastream.v1alpha1.CreateStreamRequest; +import com.google.cloud.datastream.v1alpha1.DeleteConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.DeleteRouteRequest; +import com.google.cloud.datastream.v1alpha1.DeleteStreamRequest; +import com.google.cloud.datastream.v1alpha1.DiscoverConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DiscoverConnectionProfileResponse; +import com.google.cloud.datastream.v1alpha1.FetchErrorsRequest; +import com.google.cloud.datastream.v1alpha1.FetchErrorsResponse; +import com.google.cloud.datastream.v1alpha1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1alpha1.FetchStaticIpsResponse; +import com.google.cloud.datastream.v1alpha1.GetConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.GetPrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.GetRouteRequest; +import com.google.cloud.datastream.v1alpha1.GetStreamRequest; +import com.google.cloud.datastream.v1alpha1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1alpha1.ListConnectionProfilesResponse; +import com.google.cloud.datastream.v1alpha1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1alpha1.ListPrivateConnectionsResponse; +import com.google.cloud.datastream.v1alpha1.ListRoutesRequest; +import com.google.cloud.datastream.v1alpha1.ListRoutesResponse; +import com.google.cloud.datastream.v1alpha1.ListStreamsRequest; +import com.google.cloud.datastream.v1alpha1.ListStreamsResponse; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.UpdateConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.UpdateStreamRequest; +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 Datastream service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDatastreamStub extends DatastreamStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Route.getDescriptor()) + .add(FetchErrorsResponse.getDescriptor()) + .add(ConnectionProfile.getDescriptor()) + .add(Stream.getDescriptor()) + .add(PrivateConnection.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListConnectionProfilesRequest, ListConnectionProfilesResponse> + listConnectionProfilesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/ListConnectionProfiles") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/connectionProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListConnectionProfilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/GetConnectionProfile") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/connectionProfiles/*}", + 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(ConnectionProfile.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/CreateConnectionProfile") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/connectionProfiles", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "connectionProfileId", request.getConnectionProfileId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("connectionProfile", request.getConnectionProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConnectionProfileRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/UpdateConnectionProfile") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{connectionProfile.name=projects/*/locations/*/connectionProfiles/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "connectionProfile.name", + request.getConnectionProfile().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("connectionProfile", request.getConnectionProfile())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateConnectionProfileRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteConnectionProfileMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/DeleteConnectionProfile") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/connectionProfiles/*}", + 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, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteConnectionProfileRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + DiscoverConnectionProfileRequest, DiscoverConnectionProfileResponse> + discoverConnectionProfileMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/DiscoverConnectionProfile") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/connectionProfiles:discover", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DiscoverConnectionProfileResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listStreamsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/ListStreams") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/streams", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListStreamsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/GetStream") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/streams/*}", + 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(Stream.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/CreateStream") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/streams", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "streamId", request.getStreamId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("stream", request.getStream())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateStreamRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/UpdateStream") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{stream.name=projects/*/locations/*/streams/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "stream.name", request.getStream().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("stream", request.getStream())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateStreamRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteStreamMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/DeleteStream") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/streams/*}", + 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, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteStreamRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + fetchErrorsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/FetchErrors") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{stream=projects/*/locations/*/streams/*}:fetchErrors", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "stream", request.getStream()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearStream().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (FetchErrorsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + fetchStaticIpsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/FetchStaticIps") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*}:fetchStaticIps", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FetchStaticIpsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createPrivateConnectionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/CreatePrivateConnection") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/privateConnections", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "privateConnectionId", request.getPrivateConnectionId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("privateConnection", request.getPrivateConnection())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreatePrivateConnectionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getPrivateConnectionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/GetPrivateConnection") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/privateConnections/*}", + 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(PrivateConnection.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListPrivateConnectionsRequest, ListPrivateConnectionsResponse> + listPrivateConnectionsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/ListPrivateConnections") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/privateConnections", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListPrivateConnectionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deletePrivateConnectionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.datastream.v1alpha1.Datastream/DeletePrivateConnection") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/privateConnections/*}", + 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, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeletePrivateConnectionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createRouteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/CreateRoute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*/privateConnections/*}/routes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "routeId", request.getRouteId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("route", request.getRoute())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateRouteRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getRouteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/GetRoute") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/privateConnections/*/routes/*}", + 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(Route.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listRoutesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/ListRoutes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*/privateConnections/*}/routes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListRoutesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteRouteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datastream.v1alpha1.Datastream/DeleteRoute") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*/privateConnections/*/routes/*}", + 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, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteRouteRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listConnectionProfilesCallable; + private final UnaryCallable + listConnectionProfilesPagedCallable; + private final UnaryCallable + getConnectionProfileCallable; + private final UnaryCallable + createConnectionProfileCallable; + private final OperationCallable< + CreateConnectionProfileRequest, ConnectionProfile, OperationMetadata> + createConnectionProfileOperationCallable; + private final UnaryCallable + updateConnectionProfileCallable; + private final OperationCallable< + UpdateConnectionProfileRequest, ConnectionProfile, OperationMetadata> + updateConnectionProfileOperationCallable; + private final UnaryCallable + deleteConnectionProfileCallable; + private final OperationCallable + deleteConnectionProfileOperationCallable; + private final UnaryCallable + discoverConnectionProfileCallable; + private final UnaryCallable listStreamsCallable; + private final UnaryCallable + listStreamsPagedCallable; + private final UnaryCallable getStreamCallable; + private final UnaryCallable createStreamCallable; + private final OperationCallable + createStreamOperationCallable; + private final UnaryCallable updateStreamCallable; + private final OperationCallable + updateStreamOperationCallable; + private final UnaryCallable deleteStreamCallable; + private final OperationCallable + deleteStreamOperationCallable; + private final UnaryCallable fetchErrorsCallable; + private final OperationCallable + fetchErrorsOperationCallable; + private final UnaryCallable fetchStaticIpsCallable; + private final UnaryCallable + fetchStaticIpsPagedCallable; + private final UnaryCallable + createPrivateConnectionCallable; + private final OperationCallable< + CreatePrivateConnectionRequest, PrivateConnection, OperationMetadata> + createPrivateConnectionOperationCallable; + private final UnaryCallable + getPrivateConnectionCallable; + private final UnaryCallable + listPrivateConnectionsCallable; + private final UnaryCallable + listPrivateConnectionsPagedCallable; + private final UnaryCallable + deletePrivateConnectionCallable; + private final OperationCallable + deletePrivateConnectionOperationCallable; + private final UnaryCallable createRouteCallable; + private final OperationCallable + createRouteOperationCallable; + private final UnaryCallable getRouteCallable; + private final UnaryCallable listRoutesCallable; + private final UnaryCallable listRoutesPagedCallable; + private final UnaryCallable deleteRouteCallable; + private final OperationCallable + deleteRouteOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDatastreamStub create(DatastreamStubSettings settings) + throws IOException { + return new HttpJsonDatastreamStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDatastreamStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDatastreamStub( + DatastreamStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDatastreamStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDatastreamStub( + DatastreamStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDatastreamStub, 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 HttpJsonDatastreamStub(DatastreamStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDatastreamCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDatastreamStub, 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 HttpJsonDatastreamStub( + DatastreamStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listConnectionProfilesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConnectionProfilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConnectionProfileTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + discoverConnectionProfileTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(discoverConnectionProfileMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listStreamsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listStreamsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteStreamTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteStreamMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings fetchErrorsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(fetchErrorsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + fetchStaticIpsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(fetchStaticIpsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createPrivateConnectionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createPrivateConnectionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getPrivateConnectionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPrivateConnectionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listPrivateConnectionsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listPrivateConnectionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deletePrivateConnectionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePrivateConnectionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createRouteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createRouteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getRouteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRouteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listRoutesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listRoutesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteRouteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteRouteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listConnectionProfilesCallable = + callableFactory.createUnaryCallable( + listConnectionProfilesTransportSettings, + settings.listConnectionProfilesSettings(), + clientContext); + this.listConnectionProfilesPagedCallable = + callableFactory.createPagedCallable( + listConnectionProfilesTransportSettings, + settings.listConnectionProfilesSettings(), + clientContext); + this.getConnectionProfileCallable = + callableFactory.createUnaryCallable( + getConnectionProfileTransportSettings, + settings.getConnectionProfileSettings(), + clientContext); + this.createConnectionProfileCallable = + callableFactory.createUnaryCallable( + createConnectionProfileTransportSettings, + settings.createConnectionProfileSettings(), + clientContext); + this.createConnectionProfileOperationCallable = + callableFactory.createOperationCallable( + createConnectionProfileTransportSettings, + settings.createConnectionProfileOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateConnectionProfileCallable = + callableFactory.createUnaryCallable( + updateConnectionProfileTransportSettings, + settings.updateConnectionProfileSettings(), + clientContext); + this.updateConnectionProfileOperationCallable = + callableFactory.createOperationCallable( + updateConnectionProfileTransportSettings, + settings.updateConnectionProfileOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteConnectionProfileCallable = + callableFactory.createUnaryCallable( + deleteConnectionProfileTransportSettings, + settings.deleteConnectionProfileSettings(), + clientContext); + this.deleteConnectionProfileOperationCallable = + callableFactory.createOperationCallable( + deleteConnectionProfileTransportSettings, + settings.deleteConnectionProfileOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.discoverConnectionProfileCallable = + callableFactory.createUnaryCallable( + discoverConnectionProfileTransportSettings, + settings.discoverConnectionProfileSettings(), + clientContext); + this.listStreamsCallable = + callableFactory.createUnaryCallable( + listStreamsTransportSettings, settings.listStreamsSettings(), clientContext); + this.listStreamsPagedCallable = + callableFactory.createPagedCallable( + listStreamsTransportSettings, settings.listStreamsSettings(), clientContext); + this.getStreamCallable = + callableFactory.createUnaryCallable( + getStreamTransportSettings, settings.getStreamSettings(), clientContext); + this.createStreamCallable = + callableFactory.createUnaryCallable( + createStreamTransportSettings, settings.createStreamSettings(), clientContext); + this.createStreamOperationCallable = + callableFactory.createOperationCallable( + createStreamTransportSettings, + settings.createStreamOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateStreamCallable = + callableFactory.createUnaryCallable( + updateStreamTransportSettings, settings.updateStreamSettings(), clientContext); + this.updateStreamOperationCallable = + callableFactory.createOperationCallable( + updateStreamTransportSettings, + settings.updateStreamOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteStreamCallable = + callableFactory.createUnaryCallable( + deleteStreamTransportSettings, settings.deleteStreamSettings(), clientContext); + this.deleteStreamOperationCallable = + callableFactory.createOperationCallable( + deleteStreamTransportSettings, + settings.deleteStreamOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.fetchErrorsCallable = + callableFactory.createUnaryCallable( + fetchErrorsTransportSettings, settings.fetchErrorsSettings(), clientContext); + this.fetchErrorsOperationCallable = + callableFactory.createOperationCallable( + fetchErrorsTransportSettings, + settings.fetchErrorsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.fetchStaticIpsCallable = + callableFactory.createUnaryCallable( + fetchStaticIpsTransportSettings, settings.fetchStaticIpsSettings(), clientContext); + this.fetchStaticIpsPagedCallable = + callableFactory.createPagedCallable( + fetchStaticIpsTransportSettings, settings.fetchStaticIpsSettings(), clientContext); + this.createPrivateConnectionCallable = + callableFactory.createUnaryCallable( + createPrivateConnectionTransportSettings, + settings.createPrivateConnectionSettings(), + clientContext); + this.createPrivateConnectionOperationCallable = + callableFactory.createOperationCallable( + createPrivateConnectionTransportSettings, + settings.createPrivateConnectionOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getPrivateConnectionCallable = + callableFactory.createUnaryCallable( + getPrivateConnectionTransportSettings, + settings.getPrivateConnectionSettings(), + clientContext); + this.listPrivateConnectionsCallable = + callableFactory.createUnaryCallable( + listPrivateConnectionsTransportSettings, + settings.listPrivateConnectionsSettings(), + clientContext); + this.listPrivateConnectionsPagedCallable = + callableFactory.createPagedCallable( + listPrivateConnectionsTransportSettings, + settings.listPrivateConnectionsSettings(), + clientContext); + this.deletePrivateConnectionCallable = + callableFactory.createUnaryCallable( + deletePrivateConnectionTransportSettings, + settings.deletePrivateConnectionSettings(), + clientContext); + this.deletePrivateConnectionOperationCallable = + callableFactory.createOperationCallable( + deletePrivateConnectionTransportSettings, + settings.deletePrivateConnectionOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createRouteCallable = + callableFactory.createUnaryCallable( + createRouteTransportSettings, settings.createRouteSettings(), clientContext); + this.createRouteOperationCallable = + callableFactory.createOperationCallable( + createRouteTransportSettings, + settings.createRouteOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getRouteCallable = + callableFactory.createUnaryCallable( + getRouteTransportSettings, settings.getRouteSettings(), clientContext); + this.listRoutesCallable = + callableFactory.createUnaryCallable( + listRoutesTransportSettings, settings.listRoutesSettings(), clientContext); + this.listRoutesPagedCallable = + callableFactory.createPagedCallable( + listRoutesTransportSettings, settings.listRoutesSettings(), clientContext); + this.deleteRouteCallable = + callableFactory.createUnaryCallable( + deleteRouteTransportSettings, settings.deleteRouteSettings(), clientContext); + this.deleteRouteOperationCallable = + callableFactory.createOperationCallable( + deleteRouteTransportSettings, + settings.deleteRouteOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listConnectionProfilesMethodDescriptor); + methodDescriptors.add(getConnectionProfileMethodDescriptor); + methodDescriptors.add(createConnectionProfileMethodDescriptor); + methodDescriptors.add(updateConnectionProfileMethodDescriptor); + methodDescriptors.add(deleteConnectionProfileMethodDescriptor); + methodDescriptors.add(discoverConnectionProfileMethodDescriptor); + methodDescriptors.add(listStreamsMethodDescriptor); + methodDescriptors.add(getStreamMethodDescriptor); + methodDescriptors.add(createStreamMethodDescriptor); + methodDescriptors.add(updateStreamMethodDescriptor); + methodDescriptors.add(deleteStreamMethodDescriptor); + methodDescriptors.add(fetchErrorsMethodDescriptor); + methodDescriptors.add(fetchStaticIpsMethodDescriptor); + methodDescriptors.add(createPrivateConnectionMethodDescriptor); + methodDescriptors.add(getPrivateConnectionMethodDescriptor); + methodDescriptors.add(listPrivateConnectionsMethodDescriptor); + methodDescriptors.add(deletePrivateConnectionMethodDescriptor); + methodDescriptors.add(createRouteMethodDescriptor); + methodDescriptors.add(getRouteMethodDescriptor); + methodDescriptors.add(listRoutesMethodDescriptor); + methodDescriptors.add(deleteRouteMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listConnectionProfilesCallable() { + return listConnectionProfilesCallable; + } + + @Override + public UnaryCallable + listConnectionProfilesPagedCallable() { + return listConnectionProfilesPagedCallable; + } + + @Override + public UnaryCallable + getConnectionProfileCallable() { + return getConnectionProfileCallable; + } + + @Override + public UnaryCallable + createConnectionProfileCallable() { + return createConnectionProfileCallable; + } + + @Override + public OperationCallable + createConnectionProfileOperationCallable() { + return createConnectionProfileOperationCallable; + } + + @Override + public UnaryCallable + updateConnectionProfileCallable() { + return updateConnectionProfileCallable; + } + + @Override + public OperationCallable + updateConnectionProfileOperationCallable() { + return updateConnectionProfileOperationCallable; + } + + @Override + public UnaryCallable + deleteConnectionProfileCallable() { + return deleteConnectionProfileCallable; + } + + @Override + public OperationCallable + deleteConnectionProfileOperationCallable() { + return deleteConnectionProfileOperationCallable; + } + + @Override + public UnaryCallable + discoverConnectionProfileCallable() { + return discoverConnectionProfileCallable; + } + + @Override + public UnaryCallable listStreamsCallable() { + return listStreamsCallable; + } + + @Override + public UnaryCallable listStreamsPagedCallable() { + return listStreamsPagedCallable; + } + + @Override + public UnaryCallable getStreamCallable() { + return getStreamCallable; + } + + @Override + public UnaryCallable createStreamCallable() { + return createStreamCallable; + } + + @Override + public OperationCallable + createStreamOperationCallable() { + return createStreamOperationCallable; + } + + @Override + public UnaryCallable updateStreamCallable() { + return updateStreamCallable; + } + + @Override + public OperationCallable + updateStreamOperationCallable() { + return updateStreamOperationCallable; + } + + @Override + public UnaryCallable deleteStreamCallable() { + return deleteStreamCallable; + } + + @Override + public OperationCallable + deleteStreamOperationCallable() { + return deleteStreamOperationCallable; + } + + @Override + public UnaryCallable fetchErrorsCallable() { + return fetchErrorsCallable; + } + + @Override + public OperationCallable + fetchErrorsOperationCallable() { + return fetchErrorsOperationCallable; + } + + @Override + public UnaryCallable fetchStaticIpsCallable() { + return fetchStaticIpsCallable; + } + + @Override + public UnaryCallable + fetchStaticIpsPagedCallable() { + return fetchStaticIpsPagedCallable; + } + + @Override + public UnaryCallable + createPrivateConnectionCallable() { + return createPrivateConnectionCallable; + } + + @Override + public OperationCallable + createPrivateConnectionOperationCallable() { + return createPrivateConnectionOperationCallable; + } + + @Override + public UnaryCallable + getPrivateConnectionCallable() { + return getPrivateConnectionCallable; + } + + @Override + public UnaryCallable + listPrivateConnectionsCallable() { + return listPrivateConnectionsCallable; + } + + @Override + public UnaryCallable + listPrivateConnectionsPagedCallable() { + return listPrivateConnectionsPagedCallable; + } + + @Override + public UnaryCallable + deletePrivateConnectionCallable() { + return deletePrivateConnectionCallable; + } + + @Override + public OperationCallable + deletePrivateConnectionOperationCallable() { + return deletePrivateConnectionOperationCallable; + } + + @Override + public UnaryCallable createRouteCallable() { + return createRouteCallable; + } + + @Override + public OperationCallable + createRouteOperationCallable() { + return createRouteOperationCallable; + } + + @Override + public UnaryCallable getRouteCallable() { + return getRouteCallable; + } + + @Override + public UnaryCallable listRoutesCallable() { + return listRoutesCallable; + } + + @Override + public UnaryCallable listRoutesPagedCallable() { + return listRoutesPagedCallable; + } + + @Override + public UnaryCallable deleteRouteCallable() { + return deleteRouteCallable; + } + + @Override + public OperationCallable + deleteRouteOperationCallable() { + return deleteRouteOperationCallable; + } + + @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-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1/DatastreamClientHttpJsonTest.java b/java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1/DatastreamClientHttpJsonTest.java new file mode 100644 index 000000000000..a79f4fcc18ac --- /dev/null +++ b/java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1/DatastreamClientHttpJsonTest.java @@ -0,0 +1,2641 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1; + +import static com.google.cloud.datastream.v1.DatastreamClient.FetchStaticIpsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListConnectionProfilesPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListLocationsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListPrivateConnectionsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListRoutesPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListStreamObjectsPagedResponse; +import static com.google.cloud.datastream.v1.DatastreamClient.ListStreamsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.datastream.v1.stub.HttpJsonDatastreamStub; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DatastreamClientHttpJsonTest { + private static MockHttpService mockService; + private static DatastreamClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDatastreamStub.getMethodDescriptors(), DatastreamSettings.getDefaultEndpoint()); + DatastreamSettings settings = + DatastreamSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DatastreamSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DatastreamClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listConnectionProfilesTest() throws Exception { + ConnectionProfile responsesElement = ConnectionProfile.newBuilder().build(); + ListConnectionProfilesResponse expectedResponse = + ListConnectionProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConnectionProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConnectionProfilesPagedResponse pagedListResponse = client.listConnectionProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConnectionProfilesList().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 listConnectionProfilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConnectionProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConnectionProfilesTest2() throws Exception { + ConnectionProfile responsesElement = ConnectionProfile.newBuilder().build(); + ListConnectionProfilesResponse expectedResponse = + ListConnectionProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConnectionProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListConnectionProfilesPagedResponse pagedListResponse = client.listConnectionProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConnectionProfilesList().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 listConnectionProfilesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listConnectionProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConnectionProfileTest() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + + ConnectionProfile actualResponse = client.getConnectionProfile(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 getConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + client.getConnectionProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConnectionProfileTest2() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + + ConnectionProfile actualResponse = client.getConnectionProfile(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 getConnectionProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + client.getConnectionProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConnectionProfileTest() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + + ConnectionProfile actualResponse = + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).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 createConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createConnectionProfileTest2() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + + ConnectionProfile actualResponse = + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).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 createConnectionProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateConnectionProfileTest() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ConnectionProfile connectionProfile = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ConnectionProfile actualResponse = + client.updateConnectionProfileAsync(connectionProfile, 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 updateConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConnectionProfile connectionProfile = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateConnectionProfileAsync(connectionProfile, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConnectionProfileTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + + client.deleteConnectionProfileAsync(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 deleteConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + client.deleteConnectionProfileAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConnectionProfileTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + + client.deleteConnectionProfileAsync(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 deleteConnectionProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + client.deleteConnectionProfileAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void discoverConnectionProfileTest() throws Exception { + DiscoverConnectionProfileResponse expectedResponse = + DiscoverConnectionProfileResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + + DiscoverConnectionProfileResponse actualResponse = client.discoverConnectionProfile(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void discoverConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + client.discoverConnectionProfile(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStreamsTest() throws Exception { + Stream responsesElement = Stream.newBuilder().build(); + ListStreamsResponse expectedResponse = + ListStreamsResponse.newBuilder() + .setNextPageToken("") + .addAllStreams(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListStreamsPagedResponse pagedListResponse = client.listStreams(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStreamsList().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 listStreamsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listStreams(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStreamsTest2() throws Exception { + Stream responsesElement = Stream.newBuilder().build(); + ListStreamsResponse expectedResponse = + ListStreamsResponse.newBuilder() + .setNextPageToken("") + .addAllStreams(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListStreamsPagedResponse pagedListResponse = client.listStreams(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStreamsList().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 listStreamsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listStreams(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStreamTest() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + mockService.addResponse(expectedResponse); + + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + + Stream actualResponse = client.getStream(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 getStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + client.getStream(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStreamTest2() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + + Stream actualResponse = client.getStream(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 getStreamExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + client.getStream(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStreamTest() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + + Stream actualResponse = client.createStreamAsync(parent, stream, streamId).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 createStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + client.createStreamAsync(parent, stream, streamId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createStreamTest2() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + + Stream actualResponse = client.createStreamAsync(parent, stream, streamId).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 createStreamExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + client.createStreamAsync(parent, stream, streamId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateStreamTest() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Stream stream = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Stream actualResponse = client.updateStreamAsync(stream, 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 updateStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Stream stream = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .setCustomerManagedEncryptionKey("customerManagedEncryptionKey-709617797") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateStreamAsync(stream, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteStreamTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + + client.deleteStreamAsync(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 deleteStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + client.deleteStreamAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteStreamTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + + client.deleteStreamAsync(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 deleteStreamExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + client.deleteStreamAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getStreamObjectTest() throws Exception { + StreamObject expectedResponse = + StreamObject.newBuilder() + .setName( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDisplayName("displayName1714148973") + .addAllErrors(new ArrayList()) + .setBackfillJob(BackfillJob.newBuilder().build()) + .setSourceObject(SourceObjectIdentifier.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + StreamObjectName name = StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + + StreamObject actualResponse = client.getStreamObject(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 getStreamObjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamObjectName name = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + client.getStreamObject(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStreamObjectTest2() throws Exception { + StreamObject expectedResponse = + StreamObject.newBuilder() + .setName( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDisplayName("displayName1714148973") + .addAllErrors(new ArrayList()) + .setBackfillJob(BackfillJob.newBuilder().build()) + .setSourceObject(SourceObjectIdentifier.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6471/locations/location-6471/streams/stream-6471/objects/object-6471"; + + StreamObject actualResponse = client.getStreamObject(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 getStreamObjectExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6471/locations/location-6471/streams/stream-6471/objects/object-6471"; + client.getStreamObject(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void lookupStreamObjectTest() throws Exception { + StreamObject expectedResponse = + StreamObject.newBuilder() + .setName( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDisplayName("displayName1714148973") + .addAllErrors(new ArrayList()) + .setBackfillJob(BackfillJob.newBuilder().build()) + .setSourceObject(SourceObjectIdentifier.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LookupStreamObjectRequest request = + LookupStreamObjectRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setSourceObjectIdentifier(SourceObjectIdentifier.newBuilder().build()) + .build(); + + StreamObject actualResponse = client.lookupStreamObject(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void lookupStreamObjectExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LookupStreamObjectRequest request = + LookupStreamObjectRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setSourceObjectIdentifier(SourceObjectIdentifier.newBuilder().build()) + .build(); + client.lookupStreamObject(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStreamObjectsTest() throws Exception { + StreamObject responsesElement = StreamObject.newBuilder().build(); + ListStreamObjectsResponse expectedResponse = + ListStreamObjectsResponse.newBuilder() + .setNextPageToken("") + .addAllStreamObjects(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + StreamName parent = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + + ListStreamObjectsPagedResponse pagedListResponse = client.listStreamObjects(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStreamObjectsList().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 listStreamObjectsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamName parent = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + client.listStreamObjects(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStreamObjectsTest2() throws Exception { + StreamObject responsesElement = StreamObject.newBuilder().build(); + ListStreamObjectsResponse expectedResponse = + ListStreamObjectsResponse.newBuilder() + .setNextPageToken("") + .addAllStreamObjects(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7224/locations/location-7224/streams/stream-7224"; + + ListStreamObjectsPagedResponse pagedListResponse = client.listStreamObjects(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStreamObjectsList().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 listStreamObjectsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7224/locations/location-7224/streams/stream-7224"; + client.listStreamObjects(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startBackfillJobTest() throws Exception { + StartBackfillJobResponse expectedResponse = + StartBackfillJobResponse.newBuilder().setObject(StreamObject.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + StreamObjectName object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + + StartBackfillJobResponse actualResponse = client.startBackfillJob(object); + 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 startBackfillJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamObjectName object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + client.startBackfillJob(object); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startBackfillJobTest2() throws Exception { + StartBackfillJobResponse expectedResponse = + StartBackfillJobResponse.newBuilder().setObject(StreamObject.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + String object = "projects/project-45/locations/location-45/streams/stream-45/objects/object-45"; + + StartBackfillJobResponse actualResponse = client.startBackfillJob(object); + 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 startBackfillJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String object = + "projects/project-45/locations/location-45/streams/stream-45/objects/object-45"; + client.startBackfillJob(object); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopBackfillJobTest() throws Exception { + StopBackfillJobResponse expectedResponse = + StopBackfillJobResponse.newBuilder().setObject(StreamObject.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + StreamObjectName object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + + StopBackfillJobResponse actualResponse = client.stopBackfillJob(object); + 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 stopBackfillJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamObjectName object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + client.stopBackfillJob(object); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void stopBackfillJobTest2() throws Exception { + StopBackfillJobResponse expectedResponse = + StopBackfillJobResponse.newBuilder().setObject(StreamObject.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + String object = "projects/project-45/locations/location-45/streams/stream-45/objects/object-45"; + + StopBackfillJobResponse actualResponse = client.stopBackfillJob(object); + 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 stopBackfillJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String object = + "projects/project-45/locations/location-45/streams/stream-45/objects/object-45"; + client.stopBackfillJob(object); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void fetchStaticIpsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + FetchStaticIpsResponse expectedResponse = + FetchStaticIpsResponse.newBuilder() + .setNextPageToken("") + .addAllStaticIps(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName name = LocationName.of("[PROJECT]", "[LOCATION]"); + + FetchStaticIpsPagedResponse pagedListResponse = client.fetchStaticIps(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStaticIpsList().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 fetchStaticIpsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName name = LocationName.of("[PROJECT]", "[LOCATION]"); + client.fetchStaticIps(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void fetchStaticIpsTest2() throws Exception { + String responsesElement = "responsesElement-318365110"; + FetchStaticIpsResponse expectedResponse = + FetchStaticIpsResponse.newBuilder() + .setNextPageToken("") + .addAllStaticIps(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9062/locations/location-9062"; + + FetchStaticIpsPagedResponse pagedListResponse = client.fetchStaticIps(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStaticIpsList().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 fetchStaticIpsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9062/locations/location-9062"; + client.fetchStaticIps(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPrivateConnectionTest() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + + PrivateConnection actualResponse = + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).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 createPrivateConnectionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createPrivateConnectionTest2() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + + PrivateConnection actualResponse = + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).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 createPrivateConnectionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getPrivateConnectionTest() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + + PrivateConnection actualResponse = client.getPrivateConnection(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 getPrivateConnectionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + client.getPrivateConnection(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPrivateConnectionTest2() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + + PrivateConnection actualResponse = client.getPrivateConnection(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 getPrivateConnectionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + client.getPrivateConnection(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPrivateConnectionsTest() throws Exception { + PrivateConnection responsesElement = PrivateConnection.newBuilder().build(); + ListPrivateConnectionsResponse expectedResponse = + ListPrivateConnectionsResponse.newBuilder() + .setNextPageToken("") + .addAllPrivateConnections(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListPrivateConnectionsPagedResponse pagedListResponse = client.listPrivateConnections(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPrivateConnectionsList().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 listPrivateConnectionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listPrivateConnections(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPrivateConnectionsTest2() throws Exception { + PrivateConnection responsesElement = PrivateConnection.newBuilder().build(); + ListPrivateConnectionsResponse expectedResponse = + ListPrivateConnectionsResponse.newBuilder() + .setNextPageToken("") + .addAllPrivateConnections(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListPrivateConnectionsPagedResponse pagedListResponse = client.listPrivateConnections(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPrivateConnectionsList().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 listPrivateConnectionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listPrivateConnections(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePrivateConnectionTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + + client.deletePrivateConnectionAsync(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 deletePrivateConnectionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + client.deletePrivateConnectionAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deletePrivateConnectionTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + + client.deletePrivateConnectionAsync(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 deletePrivateConnectionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + client.deletePrivateConnectionAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRouteTest() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + + Route actualResponse = client.createRouteAsync(parent, route, routeId).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 createRouteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + client.createRouteAsync(parent, route, routeId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRouteTest2() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + + Route actualResponse = client.createRouteAsync(parent, route, routeId).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 createRouteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + client.createRouteAsync(parent, route, routeId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getRouteTest() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + mockService.addResponse(expectedResponse); + + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + + Route actualResponse = client.getRoute(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 getRouteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + client.getRoute(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRouteTest2() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + + Route actualResponse = client.getRoute(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 getRouteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + client.getRoute(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRoutesTest() throws Exception { + Route responsesElement = Route.newBuilder().build(); + ListRoutesResponse expectedResponse = + ListRoutesResponse.newBuilder() + .setNextPageToken("") + .addAllRoutes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + + ListRoutesPagedResponse pagedListResponse = client.listRoutes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRoutesList().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 listRoutesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + client.listRoutes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRoutesTest2() throws Exception { + Route responsesElement = Route.newBuilder().build(); + ListRoutesResponse expectedResponse = + ListRoutesResponse.newBuilder() + .setNextPageToken("") + .addAllRoutes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + + ListRoutesPagedResponse pagedListResponse = client.listRoutes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRoutesList().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 listRoutesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + client.listRoutes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteRouteTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + + client.deleteRouteAsync(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 deleteRouteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + client.deleteRouteAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteRouteTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + + client.deleteRouteAsync(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 deleteRouteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + client.deleteRouteAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().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 listLocationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getLocationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1alpha1/DatastreamClientHttpJsonTest.java b/java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1alpha1/DatastreamClientHttpJsonTest.java new file mode 100644 index 000000000000..1c6e612504a7 --- /dev/null +++ b/java-datastream/google-cloud-datastream/src/test/java/com/google/cloud/datastream/v1alpha1/DatastreamClientHttpJsonTest.java @@ -0,0 +1,2127 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1; + +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.FetchStaticIpsPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListConnectionProfilesPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListPrivateConnectionsPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListRoutesPagedResponse; +import static com.google.cloud.datastream.v1alpha1.DatastreamClient.ListStreamsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.datastream.v1alpha1.stub.HttpJsonDatastreamStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DatastreamClientHttpJsonTest { + private static MockHttpService mockService; + private static DatastreamClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDatastreamStub.getMethodDescriptors(), DatastreamSettings.getDefaultEndpoint()); + DatastreamSettings settings = + DatastreamSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DatastreamSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DatastreamClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listConnectionProfilesTest() throws Exception { + ConnectionProfile responsesElement = ConnectionProfile.newBuilder().build(); + ListConnectionProfilesResponse expectedResponse = + ListConnectionProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConnectionProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListConnectionProfilesPagedResponse pagedListResponse = client.listConnectionProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConnectionProfilesList().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 listConnectionProfilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listConnectionProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConnectionProfilesTest2() throws Exception { + ConnectionProfile responsesElement = ConnectionProfile.newBuilder().build(); + ListConnectionProfilesResponse expectedResponse = + ListConnectionProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllConnectionProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListConnectionProfilesPagedResponse pagedListResponse = client.listConnectionProfiles(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConnectionProfilesList().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 listConnectionProfilesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listConnectionProfiles(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConnectionProfileTest() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + + ConnectionProfile actualResponse = client.getConnectionProfile(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 getConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + client.getConnectionProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConnectionProfileTest2() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + + ConnectionProfile actualResponse = client.getConnectionProfile(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 getConnectionProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + client.getConnectionProfile(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConnectionProfileTest() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + + ConnectionProfile actualResponse = + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).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 createConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createConnectionProfileTest2() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + + ConnectionProfile actualResponse = + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).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 createConnectionProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + client.createConnectionProfileAsync(parent, connectionProfile, connectionProfileId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateConnectionProfileTest() throws Exception { + ConnectionProfile expectedResponse = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ConnectionProfile connectionProfile = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ConnectionProfile actualResponse = + client.updateConnectionProfileAsync(connectionProfile, 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 updateConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConnectionProfile connectionProfile = + ConnectionProfile.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateConnectionProfileAsync(connectionProfile, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConnectionProfileTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + + client.deleteConnectionProfileAsync(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 deleteConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + client.deleteConnectionProfileAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConnectionProfileTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConnectionProfileTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + + client.deleteConnectionProfileAsync(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 deleteConnectionProfileExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9560/locations/location-9560/connectionProfiles/connectionProfile-9560"; + client.deleteConnectionProfileAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void discoverConnectionProfileTest() throws Exception { + DiscoverConnectionProfileResponse expectedResponse = + DiscoverConnectionProfileResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + + DiscoverConnectionProfileResponse actualResponse = client.discoverConnectionProfile(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void discoverConnectionProfileExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + client.discoverConnectionProfile(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStreamsTest() throws Exception { + Stream responsesElement = Stream.newBuilder().build(); + ListStreamsResponse expectedResponse = + ListStreamsResponse.newBuilder() + .setNextPageToken("") + .addAllStreams(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListStreamsPagedResponse pagedListResponse = client.listStreams(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStreamsList().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 listStreamsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listStreams(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listStreamsTest2() throws Exception { + Stream responsesElement = Stream.newBuilder().build(); + ListStreamsResponse expectedResponse = + ListStreamsResponse.newBuilder() + .setNextPageToken("") + .addAllStreams(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListStreamsPagedResponse pagedListResponse = client.listStreams(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStreamsList().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 listStreamsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listStreams(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStreamTest() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + + Stream actualResponse = client.getStream(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 getStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + client.getStream(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getStreamTest2() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + + Stream actualResponse = client.getStream(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 getStreamExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + client.getStream(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createStreamTest() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + + Stream actualResponse = client.createStreamAsync(parent, stream, streamId).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 createStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + client.createStreamAsync(parent, stream, streamId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createStreamTest2() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + + Stream actualResponse = client.createStreamAsync(parent, stream, streamId).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 createStreamExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + client.createStreamAsync(parent, stream, streamId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateStreamTest() throws Exception { + Stream expectedResponse = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Stream stream = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Stream actualResponse = client.updateStreamAsync(stream, 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 updateStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Stream stream = + Stream.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setSourceConfig(SourceConfig.newBuilder().build()) + .setDestinationConfig(DestinationConfig.newBuilder().build()) + .addAllErrors(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateStreamAsync(stream, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteStreamTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + + client.deleteStreamAsync(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 deleteStreamExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + client.deleteStreamAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteStreamTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteStreamTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + + client.deleteStreamAsync(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 deleteStreamExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3433/locations/location-3433/streams/stream-3433"; + client.deleteStreamAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void fetchErrorsTest() throws Exception { + FetchErrorsResponse expectedResponse = + FetchErrorsResponse.newBuilder().addAllErrors(new ArrayList()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("fetchErrorsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + FetchErrorsRequest request = + FetchErrorsRequest.newBuilder() + .setStream(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + + FetchErrorsResponse actualResponse = client.fetchErrorsAsync(request).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 fetchErrorsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FetchErrorsRequest request = + FetchErrorsRequest.newBuilder() + .setStream(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + client.fetchErrorsAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void fetchStaticIpsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + FetchStaticIpsResponse expectedResponse = + FetchStaticIpsResponse.newBuilder() + .setNextPageToken("") + .addAllStaticIps(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName name = LocationName.of("[PROJECT]", "[LOCATION]"); + + FetchStaticIpsPagedResponse pagedListResponse = client.fetchStaticIps(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStaticIpsList().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 fetchStaticIpsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName name = LocationName.of("[PROJECT]", "[LOCATION]"); + client.fetchStaticIps(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void fetchStaticIpsTest2() throws Exception { + String responsesElement = "responsesElement-318365110"; + FetchStaticIpsResponse expectedResponse = + FetchStaticIpsResponse.newBuilder() + .setNextPageToken("") + .addAllStaticIps(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9062/locations/location-9062"; + + FetchStaticIpsPagedResponse pagedListResponse = client.fetchStaticIps(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStaticIpsList().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 fetchStaticIpsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9062/locations/location-9062"; + client.fetchStaticIps(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPrivateConnectionTest() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + + PrivateConnection actualResponse = + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).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 createPrivateConnectionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createPrivateConnectionTest2() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + + PrivateConnection actualResponse = + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).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 createPrivateConnectionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + client.createPrivateConnectionAsync(parent, privateConnection, privateConnectionId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getPrivateConnectionTest() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + + PrivateConnection actualResponse = client.getPrivateConnection(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 getPrivateConnectionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + client.getPrivateConnection(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPrivateConnectionTest2() throws Exception { + PrivateConnection expectedResponse = + PrivateConnection.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setError(Error.newBuilder().build()) + .setVpcPeeringConfig(VpcPeeringConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + + PrivateConnection actualResponse = client.getPrivateConnection(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 getPrivateConnectionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + client.getPrivateConnection(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPrivateConnectionsTest() throws Exception { + PrivateConnection responsesElement = PrivateConnection.newBuilder().build(); + ListPrivateConnectionsResponse expectedResponse = + ListPrivateConnectionsResponse.newBuilder() + .setNextPageToken("") + .addAllPrivateConnections(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListPrivateConnectionsPagedResponse pagedListResponse = client.listPrivateConnections(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPrivateConnectionsList().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 listPrivateConnectionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listPrivateConnections(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPrivateConnectionsTest2() throws Exception { + PrivateConnection responsesElement = PrivateConnection.newBuilder().build(); + ListPrivateConnectionsResponse expectedResponse = + ListPrivateConnectionsResponse.newBuilder() + .setNextPageToken("") + .addAllPrivateConnections(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListPrivateConnectionsPagedResponse pagedListResponse = client.listPrivateConnections(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPrivateConnectionsList().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 listPrivateConnectionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listPrivateConnections(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePrivateConnectionTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + + client.deletePrivateConnectionAsync(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 deletePrivateConnectionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + client.deletePrivateConnectionAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deletePrivateConnectionTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePrivateConnectionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + + client.deletePrivateConnectionAsync(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 deletePrivateConnectionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9090/locations/location-9090/privateConnections/privateConnection-9090"; + client.deletePrivateConnectionAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRouteTest() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + + Route actualResponse = client.createRouteAsync(parent, route, routeId).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 createRouteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + client.createRouteAsync(parent, route, routeId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRouteTest2() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + + Route actualResponse = client.createRouteAsync(parent, route, routeId).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 createRouteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + client.createRouteAsync(parent, route, routeId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getRouteTest() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + mockService.addResponse(expectedResponse); + + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + + Route actualResponse = client.getRoute(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 getRouteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + client.getRoute(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRouteTest2() throws Exception { + Route expectedResponse = + Route.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setDestinationAddress("destinationAddress1736827910") + .setDestinationPort(1205298706) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + + Route actualResponse = client.getRoute(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 getRouteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + client.getRoute(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRoutesTest() throws Exception { + Route responsesElement = Route.newBuilder().build(); + ListRoutesResponse expectedResponse = + ListRoutesResponse.newBuilder() + .setNextPageToken("") + .addAllRoutes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + + ListRoutesPagedResponse pagedListResponse = client.listRoutes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRoutesList().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 listRoutesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + client.listRoutes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRoutesTest2() throws Exception { + Route responsesElement = Route.newBuilder().build(); + ListRoutesResponse expectedResponse = + ListRoutesResponse.newBuilder() + .setNextPageToken("") + .addAllRoutes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + + ListRoutesPagedResponse pagedListResponse = client.listRoutes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRoutesList().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 listRoutesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-9165/locations/location-9165/privateConnections/privateConnection-9165"; + client.listRoutes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteRouteTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + + client.deleteRouteAsync(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 deleteRouteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + client.deleteRouteAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteRouteTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRouteTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + + client.deleteRouteAsync(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 deleteRouteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9342/locations/location-9342/privateConnections/privateConnection-9342/routes/route-9342"; + client.deleteRouteAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetCredentialsProvider.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..0eafde968112 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DatastreamSettings; +import com.google.cloud.datastream.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DatastreamSettings datastreamSettings = + DatastreamSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); + } +} +// [END datastream_v1_generated_datastreamclient_create_setcredentialsprovider_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetCredentialsProvider1.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..906399c22e3a --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_create_setcredentialsprovider1_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DatastreamSettings; + +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. + DatastreamSettings datastreamSettings = + DatastreamSettings.newBuilder() + .setTransportChannelProvider( + DatastreamSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); + } +} +// [END datastream_v1_generated_datastreamclient_create_setcredentialsprovider1_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetEndpoint.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..8640c5293041 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_create_setendpoint_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DatastreamSettings; +import com.google.cloud.datastream.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DatastreamSettings datastreamSettings = + DatastreamSettings.newBuilder().setEndpoint(myEndpoint).build(); + DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); + } +} +// [END datastream_v1_generated_datastreamclient_create_setendpoint_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java new file mode 100644 index 000000000000..9ae734c70c52 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncCreateConnectionProfile(); + } + + public static void asyncCreateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateConnectionProfileRequest request = + CreateConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setConnectionProfileId("connectionProfileId597575526") + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ApiFuture future = + datastreamClient.createConnectionProfileCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java new file mode 100644 index 000000000000..12bb2a4d4600 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createconnectionprofile_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.OperationMetadata; + +public class AsyncCreateConnectionProfileLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConnectionProfileLRO(); + } + + public static void asyncCreateConnectionProfileLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateConnectionProfileRequest request = + CreateConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setConnectionProfileId("connectionProfileId597575526") + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.createConnectionProfileOperationCallable().futureCall(request); + // Do something. + ConnectionProfile response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createconnectionprofile_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.java new file mode 100644 index 000000000000..aec1f731516c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createconnectionprofile_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncCreateConnectionProfile { + + public static void main(String[] args) throws Exception { + syncCreateConnectionProfile(); + } + + public static void syncCreateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateConnectionProfileRequest request = + CreateConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setConnectionProfileId("connectionProfileId597575526") + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ConnectionProfile response = datastreamClient.createConnectionProfileAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.java new file mode 100644 index 000000000000..0ac05ae82c98 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_createconnectionprofile_locationnameconnectionprofilestring_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncCreateConnectionProfileLocationnameConnectionprofileString { + + public static void main(String[] args) throws Exception { + syncCreateConnectionProfileLocationnameConnectionprofileString(); + } + + public static void syncCreateConnectionProfileLocationnameConnectionprofileString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + ConnectionProfile response = + datastreamClient + .createConnectionProfileAsync(parent, connectionProfile, connectionProfileId) + .get(); + } + } +} +// [END +// datastream_v1_generated_datastreamclient_createconnectionprofile_locationnameconnectionprofilestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.java new file mode 100644 index 000000000000..6a94c620aee8 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_createconnectionprofile_stringconnectionprofilestring_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncCreateConnectionProfileStringConnectionprofileString { + + public static void main(String[] args) throws Exception { + syncCreateConnectionProfileStringConnectionprofileString(); + } + + public static void syncCreateConnectionProfileStringConnectionprofileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + ConnectionProfile response = + datastreamClient + .createConnectionProfileAsync(parent, connectionProfile, connectionProfileId) + .get(); + } + } +} +// [END +// datastream_v1_generated_datastreamclient_createconnectionprofile_stringconnectionprofilestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.java new file mode 100644 index 000000000000..43946d2f61be --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createprivateconnection_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.longrunning.Operation; + +public class AsyncCreatePrivateConnection { + + public static void main(String[] args) throws Exception { + asyncCreatePrivateConnection(); + } + + public static void asyncCreatePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreatePrivateConnectionRequest request = + CreatePrivateConnectionRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPrivateConnectionId("privateConnectionId-1926654532") + .setPrivateConnection(PrivateConnection.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + datastreamClient.createPrivateConnectionCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createprivateconnection_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.java new file mode 100644 index 000000000000..b724fffcd042 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createprivateconnection_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class AsyncCreatePrivateConnectionLRO { + + public static void main(String[] args) throws Exception { + asyncCreatePrivateConnectionLRO(); + } + + public static void asyncCreatePrivateConnectionLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreatePrivateConnectionRequest request = + CreatePrivateConnectionRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPrivateConnectionId("privateConnectionId-1926654532") + .setPrivateConnection(PrivateConnection.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.createPrivateConnectionOperationCallable().futureCall(request); + // Do something. + PrivateConnection response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createprivateconnection_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.java new file mode 100644 index 000000000000..2fa654b16beb --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createprivateconnection_sync] +import com.google.cloud.datastream.v1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class SyncCreatePrivateConnection { + + public static void main(String[] args) throws Exception { + syncCreatePrivateConnection(); + } + + public static void syncCreatePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreatePrivateConnectionRequest request = + CreatePrivateConnectionRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPrivateConnectionId("privateConnectionId-1926654532") + .setPrivateConnection(PrivateConnection.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + PrivateConnection response = datastreamClient.createPrivateConnectionAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createprivateconnection_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.java new file mode 100644 index 000000000000..746b16b8c203 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_createprivateconnection_locationnameprivateconnectionstring_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class SyncCreatePrivateConnectionLocationnamePrivateconnectionString { + + public static void main(String[] args) throws Exception { + syncCreatePrivateConnectionLocationnamePrivateconnectionString(); + } + + public static void syncCreatePrivateConnectionLocationnamePrivateconnectionString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + PrivateConnection response = + datastreamClient + .createPrivateConnectionAsync(parent, privateConnection, privateConnectionId) + .get(); + } + } +} +// [END +// datastream_v1_generated_datastreamclient_createprivateconnection_locationnameprivateconnectionstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.java new file mode 100644 index 000000000000..328819c655a7 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_createprivateconnection_stringprivateconnectionstring_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class SyncCreatePrivateConnectionStringPrivateconnectionString { + + public static void main(String[] args) throws Exception { + syncCreatePrivateConnectionStringPrivateconnectionString(); + } + + public static void syncCreatePrivateConnectionStringPrivateconnectionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + PrivateConnection response = + datastreamClient + .createPrivateConnectionAsync(parent, privateConnection, privateConnectionId) + .get(); + } + } +} +// [END +// datastream_v1_generated_datastreamclient_createprivateconnection_stringprivateconnectionstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRoute.java new file mode 100644 index 000000000000..aa6ae727c227 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRoute.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createroute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.CreateRouteRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; +import com.google.longrunning.Operation; + +public class AsyncCreateRoute { + + public static void main(String[] args) throws Exception { + asyncCreateRoute(); + } + + public static void asyncCreateRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateRouteRequest request = + CreateRouteRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRouteId("routeId1385647428") + .setRoute(Route.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = datastreamClient.createRouteCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createroute_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRouteLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRouteLRO.java new file mode 100644 index 000000000000..32f2c6021600 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/AsyncCreateRouteLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createroute_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.CreateRouteRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class AsyncCreateRouteLRO { + + public static void main(String[] args) throws Exception { + asyncCreateRouteLRO(); + } + + public static void asyncCreateRouteLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateRouteRequest request = + CreateRouteRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRouteId("routeId1385647428") + .setRoute(Route.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.createRouteOperationCallable().futureCall(request); + // Do something. + Route response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createroute_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoute.java new file mode 100644 index 000000000000..a68f373adb62 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoute.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createroute_sync] +import com.google.cloud.datastream.v1.CreateRouteRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class SyncCreateRoute { + + public static void main(String[] args) throws Exception { + syncCreateRoute(); + } + + public static void syncCreateRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateRouteRequest request = + CreateRouteRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRouteId("routeId1385647428") + .setRoute(Route.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + Route response = datastreamClient.createRouteAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createroute_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.java new file mode 100644 index 000000000000..e11b4ec7e049 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_createroute_privateconnectionnameroutestring_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class SyncCreateRoutePrivateconnectionnameRouteString { + + public static void main(String[] args) throws Exception { + syncCreateRoutePrivateconnectionnameRouteString(); + } + + public static void syncCreateRoutePrivateconnectionnameRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + Route response = datastreamClient.createRouteAsync(parent, route, routeId).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createroute_privateconnectionnameroutestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRouteStringRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRouteStringRouteString.java new file mode 100644 index 000000000000..c1be72c3d273 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createroute/SyncCreateRouteStringRouteString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createroute_stringroutestring_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class SyncCreateRouteStringRouteString { + + public static void main(String[] args) throws Exception { + syncCreateRouteStringRouteString(); + } + + public static void syncCreateRouteStringRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + Route response = datastreamClient.createRouteAsync(parent, route, routeId).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createroute_stringroutestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStream.java new file mode 100644 index 000000000000..ab1777ce5203 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStream.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createstream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.CreateStreamRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; +import com.google.longrunning.Operation; + +public class AsyncCreateStream { + + public static void main(String[] args) throws Exception { + asyncCreateStream(); + } + + public static void asyncCreateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateStreamRequest request = + CreateStreamRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setStreamId("streamId1790933179") + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ApiFuture future = datastreamClient.createStreamCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createstream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStreamLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStreamLRO.java new file mode 100644 index 000000000000..c59f8c2c8aca --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/AsyncCreateStreamLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createstream_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.CreateStreamRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.Stream; + +public class AsyncCreateStreamLRO { + + public static void main(String[] args) throws Exception { + asyncCreateStreamLRO(); + } + + public static void asyncCreateStreamLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateStreamRequest request = + CreateStreamRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setStreamId("streamId1790933179") + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.createStreamOperationCallable().futureCall(request); + // Do something. + Stream response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createstream_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStream.java new file mode 100644 index 000000000000..25b3219099ea --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createstream_sync] +import com.google.cloud.datastream.v1.CreateStreamRequest; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class SyncCreateStream { + + public static void main(String[] args) throws Exception { + syncCreateStream(); + } + + public static void syncCreateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateStreamRequest request = + CreateStreamRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setStreamId("streamId1790933179") + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + Stream response = datastreamClient.createStreamAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createstream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.java new file mode 100644 index 000000000000..e60e857d1d16 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createstream_locationnamestreamstring_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class SyncCreateStreamLocationnameStreamString { + + public static void main(String[] args) throws Exception { + syncCreateStreamLocationnameStreamString(); + } + + public static void syncCreateStreamLocationnameStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + Stream response = datastreamClient.createStreamAsync(parent, stream, streamId).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createstream_locationnamestreamstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamStringStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamStringStreamString.java new file mode 100644 index 000000000000..39aca78d29da --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/createstream/SyncCreateStreamStringStreamString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_createstream_stringstreamstring_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class SyncCreateStreamStringStreamString { + + public static void main(String[] args) throws Exception { + syncCreateStreamStringStreamString(); + } + + public static void syncCreateStreamStringStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + Stream response = datastreamClient.createStreamAsync(parent, stream, streamId).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_createstream_stringstreamstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.java new file mode 100644 index 000000000000..32b47d6ccb5b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteConnectionProfileRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectionProfile(); + } + + public static void asyncDeleteConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteConnectionProfileRequest request = + DeleteConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + datastreamClient.deleteConnectionProfileCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.java new file mode 100644 index 000000000000..652832061afe --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteconnectionprofile_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteConnectionProfileRequest; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteConnectionProfileLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectionProfileLRO(); + } + + public static void asyncDeleteConnectionProfileLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteConnectionProfileRequest request = + DeleteConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.deleteConnectionProfileOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteconnectionprofile_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.java new file mode 100644 index 000000000000..210bb5f4d1f2 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteconnectionprofile_sync] +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteConnectionProfileRequest; + +public class SyncDeleteConnectionProfile { + + public static void main(String[] args) throws Exception { + syncDeleteConnectionProfile(); + } + + public static void syncDeleteConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteConnectionProfileRequest request = + DeleteConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + datastreamClient.deleteConnectionProfileAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.java new file mode 100644 index 000000000000..db92d4a4b392 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_deleteconnectionprofile_connectionprofilename_sync] +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; + +public class SyncDeleteConnectionProfileConnectionprofilename { + + public static void main(String[] args) throws Exception { + syncDeleteConnectionProfileConnectionprofilename(); + } + + public static void syncDeleteConnectionProfileConnectionprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + datastreamClient.deleteConnectionProfileAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteconnectionprofile_connectionprofilename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.java new file mode 100644 index 000000000000..08d48415999f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteconnectionprofile_string_sync] +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; + +public class SyncDeleteConnectionProfileString { + + public static void main(String[] args) throws Exception { + syncDeleteConnectionProfileString(); + } + + public static void syncDeleteConnectionProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]").toString(); + datastreamClient.deleteConnectionProfileAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteconnectionprofile_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.java new file mode 100644 index 000000000000..db22b7e37238 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteprivateconnection_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.longrunning.Operation; + +public class AsyncDeletePrivateConnection { + + public static void main(String[] args) throws Exception { + asyncDeletePrivateConnection(); + } + + public static void asyncDeletePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeletePrivateConnectionRequest request = + DeletePrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + ApiFuture future = + datastreamClient.deletePrivateConnectionCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteprivateconnection_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java new file mode 100644 index 000000000000..19e2d59c6196 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteprivateconnection_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.protobuf.Empty; + +public class AsyncDeletePrivateConnectionLRO { + + public static void main(String[] args) throws Exception { + asyncDeletePrivateConnectionLRO(); + } + + public static void asyncDeletePrivateConnectionLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeletePrivateConnectionRequest request = + DeletePrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.deletePrivateConnectionOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteprivateconnection_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.java new file mode 100644 index 000000000000..73cbde9666f2 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteprivateconnection_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class SyncDeletePrivateConnection { + + public static void main(String[] args) throws Exception { + syncDeletePrivateConnection(); + } + + public static void syncDeletePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeletePrivateConnectionRequest request = + DeletePrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + datastreamClient.deletePrivateConnectionAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteprivateconnection_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.java new file mode 100644 index 000000000000..ae0b9dfdea59 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_deleteprivateconnection_privateconnectionname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class SyncDeletePrivateConnectionPrivateconnectionname { + + public static void main(String[] args) throws Exception { + syncDeletePrivateConnectionPrivateconnectionname(); + } + + public static void syncDeletePrivateConnectionPrivateconnectionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + datastreamClient.deletePrivateConnectionAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteprivateconnection_privateconnectionname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.java new file mode 100644 index 000000000000..323cae74bbef --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteprivateconnection_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class SyncDeletePrivateConnectionString { + + public static void main(String[] args) throws Exception { + syncDeletePrivateConnectionString(); + } + + public static void syncDeletePrivateConnectionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + datastreamClient.deletePrivateConnectionAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteprivateconnection_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRoute.java new file mode 100644 index 000000000000..285d305edece --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRoute.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteroute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteRouteRequest; +import com.google.cloud.datastream.v1.RouteName; +import com.google.longrunning.Operation; + +public class AsyncDeleteRoute { + + public static void main(String[] args) throws Exception { + asyncDeleteRoute(); + } + + public static void asyncDeleteRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteRouteRequest request = + DeleteRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = datastreamClient.deleteRouteCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteroute_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.java new file mode 100644 index 000000000000..c726dec06fef --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteroute_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteRouteRequest; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.RouteName; +import com.google.protobuf.Empty; + +public class AsyncDeleteRouteLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteRouteLRO(); + } + + public static void asyncDeleteRouteLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteRouteRequest request = + DeleteRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.deleteRouteOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteroute_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRoute.java new file mode 100644 index 000000000000..787f642e0ea3 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRoute.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteroute_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteRouteRequest; +import com.google.cloud.datastream.v1.RouteName; + +public class SyncDeleteRoute { + + public static void main(String[] args) throws Exception { + syncDeleteRoute(); + } + + public static void syncDeleteRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteRouteRequest request = + DeleteRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + datastreamClient.deleteRouteAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteroute_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.java new file mode 100644 index 000000000000..b0869a1e19db --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteroute_routename_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.RouteName; + +public class SyncDeleteRouteRoutename { + + public static void main(String[] args) throws Exception { + syncDeleteRouteRoutename(); + } + + public static void syncDeleteRouteRoutename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + datastreamClient.deleteRouteAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteroute_routename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteString.java new file mode 100644 index 000000000000..3d19d0e297b3 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deleteroute/SyncDeleteRouteString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deleteroute_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.RouteName; + +public class SyncDeleteRouteString { + + public static void main(String[] args) throws Exception { + syncDeleteRouteString(); + } + + public static void syncDeleteRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]").toString(); + datastreamClient.deleteRouteAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deleteroute_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStream.java new file mode 100644 index 000000000000..bf37999c46dc --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deletestream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteStreamRequest; +import com.google.cloud.datastream.v1.StreamName; +import com.google.longrunning.Operation; + +public class AsyncDeleteStream { + + public static void main(String[] args) throws Exception { + asyncDeleteStream(); + } + + public static void asyncDeleteStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteStreamRequest request = + DeleteStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = datastreamClient.deleteStreamCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deletestream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStreamLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStreamLRO.java new file mode 100644 index 000000000000..84948620da91 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/AsyncDeleteStreamLRO.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deletestream_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteStreamRequest; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.StreamName; +import com.google.protobuf.Empty; + +public class AsyncDeleteStreamLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteStreamLRO(); + } + + public static void asyncDeleteStreamLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteStreamRequest request = + DeleteStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.deleteStreamOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deletestream_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStream.java new file mode 100644 index 000000000000..488c49f20488 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deletestream_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DeleteStreamRequest; +import com.google.cloud.datastream.v1.StreamName; + +public class SyncDeleteStream { + + public static void main(String[] args) throws Exception { + syncDeleteStream(); + } + + public static void syncDeleteStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteStreamRequest request = + DeleteStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setRequestId("requestId693933066") + .build(); + datastreamClient.deleteStreamAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deletestream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamStreamname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamStreamname.java new file mode 100644 index 000000000000..856057b30f6b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamStreamname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deletestream_streamname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StreamName; + +public class SyncDeleteStreamStreamname { + + public static void main(String[] args) throws Exception { + syncDeleteStreamStreamname(); + } + + public static void syncDeleteStreamStreamname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + datastreamClient.deleteStreamAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deletestream_streamname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamString.java new file mode 100644 index 000000000000..4b1e9b455d46 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/deletestream/SyncDeleteStreamString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_deletestream_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StreamName; + +public class SyncDeleteStreamString { + + public static void main(String[] args) throws Exception { + syncDeleteStreamString(); + } + + public static void syncDeleteStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString(); + datastreamClient.deleteStreamAsync(name).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_deletestream_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.java new file mode 100644 index 000000000000..c2769682c9fe --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_discoverconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DiscoverConnectionProfileRequest; +import com.google.cloud.datastream.v1.DiscoverConnectionProfileResponse; +import com.google.cloud.datastream.v1.LocationName; + +public class AsyncDiscoverConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncDiscoverConnectionProfile(); + } + + public static void asyncDiscoverConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + ApiFuture future = + datastreamClient.discoverConnectionProfileCallable().futureCall(request); + // Do something. + DiscoverConnectionProfileResponse response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_discoverconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.java new file mode 100644 index 000000000000..e73cf7bd3a9d --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_discoverconnectionprofile_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.DiscoverConnectionProfileRequest; +import com.google.cloud.datastream.v1.DiscoverConnectionProfileResponse; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncDiscoverConnectionProfile { + + public static void main(String[] args) throws Exception { + syncDiscoverConnectionProfile(); + } + + public static void syncDiscoverConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + DiscoverConnectionProfileResponse response = + datastreamClient.discoverConnectionProfile(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_discoverconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.java new file mode 100644 index 000000000000..c0a4c5c81c48 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_fetchstaticips_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1.LocationName; + +public class AsyncFetchStaticIps { + + public static void main(String[] args) throws Exception { + asyncFetchStaticIps(); + } + + public static void asyncFetchStaticIps() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchStaticIpsRequest request = + FetchStaticIpsRequest.newBuilder() + .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = datastreamClient.fetchStaticIpsPagedCallable().futureCall(request); + // Do something. + for (String element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_fetchstaticips_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.java new file mode 100644 index 000000000000..6bab8dcdb356 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_fetchstaticips_paged_async] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1.FetchStaticIpsResponse; +import com.google.cloud.datastream.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncFetchStaticIpsPaged { + + public static void main(String[] args) throws Exception { + asyncFetchStaticIpsPaged(); + } + + public static void asyncFetchStaticIpsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchStaticIpsRequest request = + FetchStaticIpsRequest.newBuilder() + .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + FetchStaticIpsResponse response = datastreamClient.fetchStaticIpsCallable().call(request); + for (String element : response.getStaticIpsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_fetchstaticips_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIps.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIps.java new file mode 100644 index 000000000000..24182d94ce5f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIps.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_fetchstaticips_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncFetchStaticIps { + + public static void main(String[] args) throws Exception { + syncFetchStaticIps(); + } + + public static void syncFetchStaticIps() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchStaticIpsRequest request = + FetchStaticIpsRequest.newBuilder() + .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (String element : datastreamClient.fetchStaticIps(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_fetchstaticips_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.java new file mode 100644 index 000000000000..e21b2bc15023 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_fetchstaticips_locationname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncFetchStaticIpsLocationname { + + public static void main(String[] args) throws Exception { + syncFetchStaticIpsLocationname(); + } + + public static void syncFetchStaticIpsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName name = LocationName.of("[PROJECT]", "[LOCATION]"); + for (String element : datastreamClient.fetchStaticIps(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_fetchstaticips_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.java new file mode 100644 index 000000000000..2ca638dac41a --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_fetchstaticips_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncFetchStaticIpsString { + + public static void main(String[] args) throws Exception { + syncFetchStaticIpsString(); + } + + public static void syncFetchStaticIpsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (String element : datastreamClient.fetchStaticIps(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_fetchstaticips_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.java new file mode 100644 index 000000000000..4da46211ec6c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetConnectionProfileRequest; + +public class AsyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncGetConnectionProfile(); + } + + public static void asyncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetConnectionProfileRequest request = + GetConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .build(); + ApiFuture future = + datastreamClient.getConnectionProfileCallable().futureCall(request); + // Do something. + ConnectionProfile response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_getconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.java new file mode 100644 index 000000000000..b176131989be --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getconnectionprofile_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetConnectionProfileRequest; + +public class SyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfile(); + } + + public static void syncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetConnectionProfileRequest request = + GetConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .build(); + ConnectionProfile response = datastreamClient.getConnectionProfile(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_getconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.java new file mode 100644 index 000000000000..9780d6e2c1b1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getconnectionprofile_connectionprofilename_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; + +public class SyncGetConnectionProfileConnectionprofilename { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfileConnectionprofilename(); + } + + public static void syncGetConnectionProfileConnectionprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + ConnectionProfile response = datastreamClient.getConnectionProfile(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getconnectionprofile_connectionprofilename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.java new file mode 100644 index 000000000000..b8bc07c61eb6 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getconnectionprofile_string_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.ConnectionProfileName; +import com.google.cloud.datastream.v1.DatastreamClient; + +public class SyncGetConnectionProfileString { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfileString(); + } + + public static void syncGetConnectionProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]").toString(); + ConnectionProfile response = datastreamClient.getConnectionProfile(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getconnectionprofile_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/AsyncGetLocation.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/AsyncGetLocation.java new file mode 100644 index 000000000000..28b0338e6813 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/AsyncGetLocation.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getlocation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.Location; + +public class AsyncGetLocation { + + public static void main(String[] args) throws Exception { + asyncGetLocation(); + } + + public static void asyncGetLocation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = datastreamClient.getLocationCallable().futureCall(request); + // Do something. + Location response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_getlocation_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/SyncGetLocation.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/SyncGetLocation.java new file mode 100644 index 000000000000..d1facc9ec0c5 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getlocation/SyncGetLocation.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getlocation_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.Location; + +public class SyncGetLocation { + + public static void main(String[] args) throws Exception { + syncGetLocation(); + } + + public static void syncGetLocation() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + Location response = datastreamClient.getLocation(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_getlocation_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.java new file mode 100644 index 000000000000..779f523358fd --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getprivateconnection_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetPrivateConnectionRequest; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class AsyncGetPrivateConnection { + + public static void main(String[] args) throws Exception { + asyncGetPrivateConnection(); + } + + public static void asyncGetPrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetPrivateConnectionRequest request = + GetPrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .build(); + ApiFuture future = + datastreamClient.getPrivateConnectionCallable().futureCall(request); + // Do something. + PrivateConnection response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_getprivateconnection_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.java new file mode 100644 index 000000000000..d915695fe124 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getprivateconnection_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetPrivateConnectionRequest; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class SyncGetPrivateConnection { + + public static void main(String[] args) throws Exception { + syncGetPrivateConnection(); + } + + public static void syncGetPrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetPrivateConnectionRequest request = + GetPrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .build(); + PrivateConnection response = datastreamClient.getPrivateConnection(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_getprivateconnection_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.java new file mode 100644 index 000000000000..7cdd509bf072 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getprivateconnection_privateconnectionname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class SyncGetPrivateConnectionPrivateconnectionname { + + public static void main(String[] args) throws Exception { + syncGetPrivateConnectionPrivateconnectionname(); + } + + public static void syncGetPrivateConnectionPrivateconnectionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + PrivateConnection response = datastreamClient.getPrivateConnection(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getprivateconnection_privateconnectionname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.java new file mode 100644 index 000000000000..1d174f197b86 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getprivateconnection_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.cloud.datastream.v1.PrivateConnectionName; + +public class SyncGetPrivateConnectionString { + + public static void main(String[] args) throws Exception { + syncGetPrivateConnectionString(); + } + + public static void syncGetPrivateConnectionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + PrivateConnection response = datastreamClient.getPrivateConnection(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getprivateconnection_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/AsyncGetRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/AsyncGetRoute.java new file mode 100644 index 000000000000..e097c40c28b8 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/AsyncGetRoute.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getroute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetRouteRequest; +import com.google.cloud.datastream.v1.Route; +import com.google.cloud.datastream.v1.RouteName; + +public class AsyncGetRoute { + + public static void main(String[] args) throws Exception { + asyncGetRoute(); + } + + public static void asyncGetRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetRouteRequest request = + GetRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .build(); + ApiFuture future = datastreamClient.getRouteCallable().futureCall(request); + // Do something. + Route response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_getroute_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRoute.java new file mode 100644 index 000000000000..280732e6d3b8 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRoute.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getroute_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetRouteRequest; +import com.google.cloud.datastream.v1.Route; +import com.google.cloud.datastream.v1.RouteName; + +public class SyncGetRoute { + + public static void main(String[] args) throws Exception { + syncGetRoute(); + } + + public static void syncGetRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetRouteRequest request = + GetRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .build(); + Route response = datastreamClient.getRoute(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_getroute_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteRoutename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteRoutename.java new file mode 100644 index 000000000000..1c36a7ebdfdf --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteRoutename.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getroute_routename_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Route; +import com.google.cloud.datastream.v1.RouteName; + +public class SyncGetRouteRoutename { + + public static void main(String[] args) throws Exception { + syncGetRouteRoutename(); + } + + public static void syncGetRouteRoutename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + Route response = datastreamClient.getRoute(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getroute_routename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteString.java new file mode 100644 index 000000000000..4883ed96ca20 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getroute/SyncGetRouteString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getroute_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Route; +import com.google.cloud.datastream.v1.RouteName; + +public class SyncGetRouteString { + + public static void main(String[] args) throws Exception { + syncGetRouteString(); + } + + public static void syncGetRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]").toString(); + Route response = datastreamClient.getRoute(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getroute_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/AsyncGetStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/AsyncGetStream.java new file mode 100644 index 000000000000..7bbc3ad9fa28 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/AsyncGetStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetStreamRequest; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.StreamName; + +public class AsyncGetStream { + + public static void main(String[] args) throws Exception { + asyncGetStream(); + } + + public static void asyncGetStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetStreamRequest request = + GetStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + ApiFuture future = datastreamClient.getStreamCallable().futureCall(request); + // Do something. + Stream response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStream.java new file mode 100644 index 000000000000..e06c26cca166 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstream_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetStreamRequest; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.StreamName; + +public class SyncGetStream { + + public static void main(String[] args) throws Exception { + syncGetStream(); + } + + public static void syncGetStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetStreamRequest request = + GetStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + Stream response = datastreamClient.getStream(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamStreamname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamStreamname.java new file mode 100644 index 000000000000..64ed4175b109 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamStreamname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstream_streamname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.StreamName; + +public class SyncGetStreamStreamname { + + public static void main(String[] args) throws Exception { + syncGetStreamStreamname(); + } + + public static void syncGetStreamStreamname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + Stream response = datastreamClient.getStream(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstream_streamname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamString.java new file mode 100644 index 000000000000..c8d12068cd91 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstream/SyncGetStreamString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstream_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.StreamName; + +public class SyncGetStreamString { + + public static void main(String[] args) throws Exception { + syncGetStreamString(); + } + + public static void syncGetStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString(); + Stream response = datastreamClient.getStream(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstream_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/AsyncGetStreamObject.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/AsyncGetStreamObject.java new file mode 100644 index 000000000000..e57ba70403cb --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/AsyncGetStreamObject.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstreamobject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetStreamObjectRequest; +import com.google.cloud.datastream.v1.StreamObject; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class AsyncGetStreamObject { + + public static void main(String[] args) throws Exception { + asyncGetStreamObject(); + } + + public static void asyncGetStreamObject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetStreamObjectRequest request = + GetStreamObjectRequest.newBuilder() + .setName( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .build(); + ApiFuture future = + datastreamClient.getStreamObjectCallable().futureCall(request); + // Do something. + StreamObject response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstreamobject_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObject.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObject.java new file mode 100644 index 000000000000..daadad9e3bb4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObject.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstreamobject_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.GetStreamObjectRequest; +import com.google.cloud.datastream.v1.StreamObject; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncGetStreamObject { + + public static void main(String[] args) throws Exception { + syncGetStreamObject(); + } + + public static void syncGetStreamObject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetStreamObjectRequest request = + GetStreamObjectRequest.newBuilder() + .setName( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .build(); + StreamObject response = datastreamClient.getStreamObject(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstreamobject_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectStreamobjectname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectStreamobjectname.java new file mode 100644 index 000000000000..80a1d92ee2c2 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectStreamobjectname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstreamobject_streamobjectname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StreamObject; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncGetStreamObjectStreamobjectname { + + public static void main(String[] args) throws Exception { + syncGetStreamObjectStreamobjectname(); + } + + public static void syncGetStreamObjectStreamobjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamObjectName name = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + StreamObject response = datastreamClient.getStreamObject(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstreamobject_streamobjectname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectString.java new file mode 100644 index 000000000000..a4cd70cb3abf --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/getstreamobject/SyncGetStreamObjectString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_getstreamobject_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StreamObject; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncGetStreamObjectString { + + public static void main(String[] args) throws Exception { + syncGetStreamObjectString(); + } + + public static void syncGetStreamObjectString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString(); + StreamObject response = datastreamClient.getStreamObject(name); + } + } +} +// [END datastream_v1_generated_datastreamclient_getstreamobject_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java new file mode 100644 index 000000000000..f280bd8eb994 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listconnectionprofiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1.LocationName; + +public class AsyncListConnectionProfiles { + + public static void main(String[] args) throws Exception { + asyncListConnectionProfiles(); + } + + public static void asyncListConnectionProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListConnectionProfilesRequest request = + ListConnectionProfilesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + datastreamClient.listConnectionProfilesPagedCallable().futureCall(request); + // Do something. + for (ConnectionProfile element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listconnectionprofiles_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java new file mode 100644 index 000000000000..8ab4f567efc1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listconnectionprofiles_paged_async] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1.ListConnectionProfilesResponse; +import com.google.cloud.datastream.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListConnectionProfilesPaged { + + public static void main(String[] args) throws Exception { + asyncListConnectionProfilesPaged(); + } + + public static void asyncListConnectionProfilesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListConnectionProfilesRequest request = + ListConnectionProfilesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListConnectionProfilesResponse response = + datastreamClient.listConnectionProfilesCallable().call(request); + for (ConnectionProfile element : response.getConnectionProfilesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listconnectionprofiles_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.java new file mode 100644 index 000000000000..d079891c46d5 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listconnectionprofiles_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncListConnectionProfiles { + + public static void main(String[] args) throws Exception { + syncListConnectionProfiles(); + } + + public static void syncListConnectionProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListConnectionProfilesRequest request = + ListConnectionProfilesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (ConnectionProfile element : + datastreamClient.listConnectionProfiles(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listconnectionprofiles_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.java new file mode 100644 index 000000000000..2e2c71aa2b93 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listconnectionprofiles_locationname_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncListConnectionProfilesLocationname { + + public static void main(String[] args) throws Exception { + syncListConnectionProfilesLocationname(); + } + + public static void syncListConnectionProfilesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ConnectionProfile element : + datastreamClient.listConnectionProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listconnectionprofiles_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.java new file mode 100644 index 000000000000..5996bf5a7017 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listconnectionprofiles_string_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; + +public class SyncListConnectionProfilesString { + + public static void main(String[] args) throws Exception { + syncListConnectionProfilesString(); + } + + public static void syncListConnectionProfilesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (ConnectionProfile element : + datastreamClient.listConnectionProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listconnectionprofiles_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocations.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocations.java new file mode 100644 index 000000000000..668593a67a1f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocations.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listlocations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; + +public class AsyncListLocations { + + public static void main(String[] args) throws Exception { + asyncListLocations(); + } + + public static void asyncListLocations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + datastreamClient.listLocationsPagedCallable().futureCall(request); + // Do something. + for (Location element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listlocations_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocationsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocationsPaged.java new file mode 100644 index 000000000000..70ddb1b51d6a --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/AsyncListLocationsPaged.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listlocations_paged_async] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.base.Strings; + +public class AsyncListLocationsPaged { + + public static void main(String[] args) throws Exception { + asyncListLocationsPaged(); + } + + public static void asyncListLocationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListLocationsResponse response = datastreamClient.listLocationsCallable().call(request); + for (Location element : response.getLocationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listlocations_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/SyncListLocations.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/SyncListLocations.java new file mode 100644 index 000000000000..cc4a6212854f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listlocations/SyncListLocations.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listlocations_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; + +public class SyncListLocations { + + public static void main(String[] args) throws Exception { + syncListLocations(); + } + + public static void syncListLocations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Location element : datastreamClient.listLocations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listlocations_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java new file mode 100644 index 000000000000..e5d8b3cabb05 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listprivateconnections_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class AsyncListPrivateConnections { + + public static void main(String[] args) throws Exception { + asyncListPrivateConnections(); + } + + public static void asyncListPrivateConnections() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListPrivateConnectionsRequest request = + ListPrivateConnectionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + datastreamClient.listPrivateConnectionsPagedCallable().futureCall(request); + // Do something. + for (PrivateConnection element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listprivateconnections_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java new file mode 100644 index 000000000000..6491deb92fde --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listprivateconnections_paged_async] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1.ListPrivateConnectionsResponse; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; +import com.google.common.base.Strings; + +public class AsyncListPrivateConnectionsPaged { + + public static void main(String[] args) throws Exception { + asyncListPrivateConnectionsPaged(); + } + + public static void asyncListPrivateConnectionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListPrivateConnectionsRequest request = + ListPrivateConnectionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListPrivateConnectionsResponse response = + datastreamClient.listPrivateConnectionsCallable().call(request); + for (PrivateConnection element : response.getPrivateConnectionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listprivateconnections_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnections.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnections.java new file mode 100644 index 000000000000..d8a36ff7d85a --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnections.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listprivateconnections_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class SyncListPrivateConnections { + + public static void main(String[] args) throws Exception { + syncListPrivateConnections(); + } + + public static void syncListPrivateConnections() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListPrivateConnectionsRequest request = + ListPrivateConnectionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (PrivateConnection element : + datastreamClient.listPrivateConnections(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listprivateconnections_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.java new file mode 100644 index 000000000000..9cb479c1c9a2 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listprivateconnections_locationname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class SyncListPrivateConnectionsLocationname { + + public static void main(String[] args) throws Exception { + syncListPrivateConnectionsLocationname(); + } + + public static void syncListPrivateConnectionsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (PrivateConnection element : + datastreamClient.listPrivateConnections(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listprivateconnections_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.java new file mode 100644 index 000000000000..c9d2fdabd1e8 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listprivateconnections_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.PrivateConnection; + +public class SyncListPrivateConnectionsString { + + public static void main(String[] args) throws Exception { + syncListPrivateConnectionsString(); + } + + public static void syncListPrivateConnectionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (PrivateConnection element : + datastreamClient.listPrivateConnections(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listprivateconnections_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutes.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutes.java new file mode 100644 index 000000000000..2b5296c143c2 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutes.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listroutes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListRoutesRequest; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class AsyncListRoutes { + + public static void main(String[] args) throws Exception { + asyncListRoutes(); + } + + public static void asyncListRoutes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListRoutesRequest request = + ListRoutesRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = datastreamClient.listRoutesPagedCallable().futureCall(request); + // Do something. + for (Route element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listroutes_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutesPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutesPaged.java new file mode 100644 index 000000000000..553ea7250424 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/AsyncListRoutesPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listroutes_paged_async] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListRoutesRequest; +import com.google.cloud.datastream.v1.ListRoutesResponse; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; +import com.google.common.base.Strings; + +public class AsyncListRoutesPaged { + + public static void main(String[] args) throws Exception { + asyncListRoutesPaged(); + } + + public static void asyncListRoutesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListRoutesRequest request = + ListRoutesRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListRoutesResponse response = datastreamClient.listRoutesCallable().call(request); + for (Route element : response.getRoutesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listroutes_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutes.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutes.java new file mode 100644 index 000000000000..e99df1386523 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutes.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listroutes_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListRoutesRequest; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class SyncListRoutes { + + public static void main(String[] args) throws Exception { + syncListRoutes(); + } + + public static void syncListRoutes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListRoutesRequest request = + ListRoutesRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Route element : datastreamClient.listRoutes(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listroutes_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.java new file mode 100644 index 000000000000..80797e38ba92 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listroutes_privateconnectionname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class SyncListRoutesPrivateconnectionname { + + public static void main(String[] args) throws Exception { + syncListRoutesPrivateconnectionname(); + } + + public static void syncListRoutesPrivateconnectionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + for (Route element : datastreamClient.listRoutes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listroutes_privateconnectionname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesString.java new file mode 100644 index 000000000000..d117db5c29e7 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/listroutes/SyncListRoutesString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_listroutes_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.PrivateConnectionName; +import com.google.cloud.datastream.v1.Route; + +public class SyncListRoutesString { + + public static void main(String[] args) throws Exception { + syncListRoutesString(); + } + + public static void syncListRoutesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + for (Route element : datastreamClient.listRoutes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_listroutes_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjects.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjects.java new file mode 100644 index 000000000000..43c870b3d1d4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjects.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreamobjects_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListStreamObjectsRequest; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; + +public class AsyncListStreamObjects { + + public static void main(String[] args) throws Exception { + asyncListStreamObjects(); + } + + public static void asyncListStreamObjects() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamObjectsRequest request = + ListStreamObjectsRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + datastreamClient.listStreamObjectsPagedCallable().futureCall(request); + // Do something. + for (StreamObject element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreamobjects_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjectsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjectsPaged.java new file mode 100644 index 000000000000..feb745d7f938 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/AsyncListStreamObjectsPaged.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreamobjects_paged_async] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListStreamObjectsRequest; +import com.google.cloud.datastream.v1.ListStreamObjectsResponse; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; +import com.google.common.base.Strings; + +public class AsyncListStreamObjectsPaged { + + public static void main(String[] args) throws Exception { + asyncListStreamObjectsPaged(); + } + + public static void asyncListStreamObjectsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamObjectsRequest request = + ListStreamObjectsRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListStreamObjectsResponse response = + datastreamClient.listStreamObjectsCallable().call(request); + for (StreamObject element : response.getStreamObjectsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreamobjects_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjects.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjects.java new file mode 100644 index 000000000000..1d63125da110 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjects.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreamobjects_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListStreamObjectsRequest; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; + +public class SyncListStreamObjects { + + public static void main(String[] args) throws Exception { + syncListStreamObjects(); + } + + public static void syncListStreamObjects() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamObjectsRequest request = + ListStreamObjectsRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (StreamObject element : datastreamClient.listStreamObjects(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreamobjects_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsStreamname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsStreamname.java new file mode 100644 index 000000000000..89146b808a57 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsStreamname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreamobjects_streamname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; + +public class SyncListStreamObjectsStreamname { + + public static void main(String[] args) throws Exception { + syncListStreamObjectsStreamname(); + } + + public static void syncListStreamObjectsStreamname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamName parent = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + for (StreamObject element : datastreamClient.listStreamObjects(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreamobjects_streamname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsString.java new file mode 100644 index 000000000000..5b120a873afd --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreamobjects/SyncListStreamObjectsString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreamobjects_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; + +public class SyncListStreamObjectsString { + + public static void main(String[] args) throws Exception { + syncListStreamObjectsString(); + } + + public static void syncListStreamObjectsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString(); + for (StreamObject element : datastreamClient.listStreamObjects(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreamobjects_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreams.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreams.java new file mode 100644 index 000000000000..642de50632ce --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreams.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreams_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListStreamsRequest; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class AsyncListStreams { + + public static void main(String[] args) throws Exception { + asyncListStreams(); + } + + public static void asyncListStreams() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamsRequest request = + ListStreamsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = datastreamClient.listStreamsPagedCallable().futureCall(request); + // Do something. + for (Stream element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreams_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreamsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreamsPaged.java new file mode 100644 index 000000000000..bf9d9a53135c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/AsyncListStreamsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreams_paged_async] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListStreamsRequest; +import com.google.cloud.datastream.v1.ListStreamsResponse; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; +import com.google.common.base.Strings; + +public class AsyncListStreamsPaged { + + public static void main(String[] args) throws Exception { + asyncListStreamsPaged(); + } + + public static void asyncListStreamsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamsRequest request = + ListStreamsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListStreamsResponse response = datastreamClient.listStreamsCallable().call(request); + for (Stream element : response.getStreamsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreams_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreams.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreams.java new file mode 100644 index 000000000000..cfda626052ae --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreams.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreams_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.ListStreamsRequest; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class SyncListStreams { + + public static void main(String[] args) throws Exception { + syncListStreams(); + } + + public static void syncListStreams() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamsRequest request = + ListStreamsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Stream element : datastreamClient.listStreams(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreams_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsLocationname.java new file mode 100644 index 000000000000..2731f0e3268c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsLocationname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreams_locationname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class SyncListStreamsLocationname { + + public static void main(String[] args) throws Exception { + syncListStreamsLocationname(); + } + + public static void syncListStreamsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Stream element : datastreamClient.listStreams(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreams_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsString.java new file mode 100644 index 000000000000..699f33800fe2 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/liststreams/SyncListStreamsString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_liststreams_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LocationName; +import com.google.cloud.datastream.v1.Stream; + +public class SyncListStreamsString { + + public static void main(String[] args) throws Exception { + syncListStreamsString(); + } + + public static void syncListStreamsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Stream element : datastreamClient.listStreams(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1_generated_datastreamclient_liststreams_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/AsyncLookupStreamObject.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/AsyncLookupStreamObject.java new file mode 100644 index 000000000000..326c6cc3a064 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/AsyncLookupStreamObject.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_lookupstreamobject_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LookupStreamObjectRequest; +import com.google.cloud.datastream.v1.SourceObjectIdentifier; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; + +public class AsyncLookupStreamObject { + + public static void main(String[] args) throws Exception { + asyncLookupStreamObject(); + } + + public static void asyncLookupStreamObject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LookupStreamObjectRequest request = + LookupStreamObjectRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setSourceObjectIdentifier(SourceObjectIdentifier.newBuilder().build()) + .build(); + ApiFuture future = + datastreamClient.lookupStreamObjectCallable().futureCall(request); + // Do something. + StreamObject response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_lookupstreamobject_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/SyncLookupStreamObject.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/SyncLookupStreamObject.java new file mode 100644 index 000000000000..0a6c1d0ffdae --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/lookupstreamobject/SyncLookupStreamObject.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_lookupstreamobject_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.LookupStreamObjectRequest; +import com.google.cloud.datastream.v1.SourceObjectIdentifier; +import com.google.cloud.datastream.v1.StreamName; +import com.google.cloud.datastream.v1.StreamObject; + +public class SyncLookupStreamObject { + + public static void main(String[] args) throws Exception { + syncLookupStreamObject(); + } + + public static void syncLookupStreamObject() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LookupStreamObjectRequest request = + LookupStreamObjectRequest.newBuilder() + .setParent(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setSourceObjectIdentifier(SourceObjectIdentifier.newBuilder().build()) + .build(); + StreamObject response = datastreamClient.lookupStreamObject(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_lookupstreamobject_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/AsyncStartBackfillJob.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/AsyncStartBackfillJob.java new file mode 100644 index 000000000000..68e69127e519 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/AsyncStartBackfillJob.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_startbackfilljob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StartBackfillJobRequest; +import com.google.cloud.datastream.v1.StartBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class AsyncStartBackfillJob { + + public static void main(String[] args) throws Exception { + asyncStartBackfillJob(); + } + + public static void asyncStartBackfillJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StartBackfillJobRequest request = + StartBackfillJobRequest.newBuilder() + .setObject( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .build(); + ApiFuture future = + datastreamClient.startBackfillJobCallable().futureCall(request); + // Do something. + StartBackfillJobResponse response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_startbackfilljob_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJob.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJob.java new file mode 100644 index 000000000000..344cfc606000 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJob.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_startbackfilljob_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StartBackfillJobRequest; +import com.google.cloud.datastream.v1.StartBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncStartBackfillJob { + + public static void main(String[] args) throws Exception { + syncStartBackfillJob(); + } + + public static void syncStartBackfillJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StartBackfillJobRequest request = + StartBackfillJobRequest.newBuilder() + .setObject( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .build(); + StartBackfillJobResponse response = datastreamClient.startBackfillJob(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_startbackfilljob_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobStreamobjectname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobStreamobjectname.java new file mode 100644 index 000000000000..d170df66df75 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobStreamobjectname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_startbackfilljob_streamobjectname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StartBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncStartBackfillJobStreamobjectname { + + public static void main(String[] args) throws Exception { + syncStartBackfillJobStreamobjectname(); + } + + public static void syncStartBackfillJobStreamobjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamObjectName object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + StartBackfillJobResponse response = datastreamClient.startBackfillJob(object); + } + } +} +// [END datastream_v1_generated_datastreamclient_startbackfilljob_streamobjectname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobString.java new file mode 100644 index 000000000000..41e84816b3a0 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/startbackfilljob/SyncStartBackfillJobString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_startbackfilljob_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StartBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncStartBackfillJobString { + + public static void main(String[] args) throws Exception { + syncStartBackfillJobString(); + } + + public static void syncStartBackfillJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString(); + StartBackfillJobResponse response = datastreamClient.startBackfillJob(object); + } + } +} +// [END datastream_v1_generated_datastreamclient_startbackfilljob_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/AsyncStopBackfillJob.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/AsyncStopBackfillJob.java new file mode 100644 index 000000000000..fc6003fa0249 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/AsyncStopBackfillJob.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_stopbackfilljob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StopBackfillJobRequest; +import com.google.cloud.datastream.v1.StopBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class AsyncStopBackfillJob { + + public static void main(String[] args) throws Exception { + asyncStopBackfillJob(); + } + + public static void asyncStopBackfillJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StopBackfillJobRequest request = + StopBackfillJobRequest.newBuilder() + .setObject( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .build(); + ApiFuture future = + datastreamClient.stopBackfillJobCallable().futureCall(request); + // Do something. + StopBackfillJobResponse response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_stopbackfilljob_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJob.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJob.java new file mode 100644 index 000000000000..5d748754da00 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJob.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_stopbackfilljob_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StopBackfillJobRequest; +import com.google.cloud.datastream.v1.StopBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncStopBackfillJob { + + public static void main(String[] args) throws Exception { + syncStopBackfillJob(); + } + + public static void syncStopBackfillJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StopBackfillJobRequest request = + StopBackfillJobRequest.newBuilder() + .setObject( + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString()) + .build(); + StopBackfillJobResponse response = datastreamClient.stopBackfillJob(request); + } + } +} +// [END datastream_v1_generated_datastreamclient_stopbackfilljob_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobStreamobjectname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobStreamobjectname.java new file mode 100644 index 000000000000..aab47b17c6ba --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobStreamobjectname.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_stopbackfilljob_streamobjectname_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StopBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncStopBackfillJobStreamobjectname { + + public static void main(String[] args) throws Exception { + syncStopBackfillJobStreamobjectname(); + } + + public static void syncStopBackfillJobStreamobjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamObjectName object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]"); + StopBackfillJobResponse response = datastreamClient.stopBackfillJob(object); + } + } +} +// [END datastream_v1_generated_datastreamclient_stopbackfilljob_streamobjectname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobString.java new file mode 100644 index 000000000000..af1d4233235f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/stopbackfilljob/SyncStopBackfillJobString.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_stopbackfilljob_string_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.StopBackfillJobResponse; +import com.google.cloud.datastream.v1.StreamObjectName; + +public class SyncStopBackfillJobString { + + public static void main(String[] args) throws Exception { + syncStopBackfillJobString(); + } + + public static void syncStopBackfillJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String object = + StreamObjectName.of("[PROJECT]", "[LOCATION]", "[STREAM]", "[OBJECT]").toString(); + StopBackfillJobResponse response = datastreamClient.stopBackfillJob(object); + } + } +} +// [END datastream_v1_generated_datastreamclient_stopbackfilljob_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java new file mode 100644 index 000000000000..ba59f850e4b1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updateconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.UpdateConnectionProfileRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectionProfile(); + } + + public static void asyncUpdateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateConnectionProfileRequest request = + UpdateConnectionProfileRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ApiFuture future = + datastreamClient.updateConnectionProfileCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updateconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java new file mode 100644 index 000000000000..ee25d636da23 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updateconnectionprofile_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.UpdateConnectionProfileRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectionProfileLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectionProfileLRO(); + } + + public static void asyncUpdateConnectionProfileLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateConnectionProfileRequest request = + UpdateConnectionProfileRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.updateConnectionProfileOperationCallable().futureCall(request); + // Do something. + ConnectionProfile response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updateconnectionprofile_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.java new file mode 100644 index 000000000000..e83322c9b650 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updateconnectionprofile_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.UpdateConnectionProfileRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectionProfile { + + public static void main(String[] args) throws Exception { + syncUpdateConnectionProfile(); + } + + public static void syncUpdateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateConnectionProfileRequest request = + UpdateConnectionProfileRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ConnectionProfile response = datastreamClient.updateConnectionProfileAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updateconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.java new file mode 100644 index 000000000000..82d2f69b84c6 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.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.datastream.v1.samples; + +// [START +// datastream_v1_generated_datastreamclient_updateconnectionprofile_connectionprofilefieldmask_sync] +import com.google.cloud.datastream.v1.ConnectionProfile; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectionProfileConnectionprofileFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateConnectionProfileConnectionprofileFieldmask(); + } + + public static void syncUpdateConnectionProfileConnectionprofileFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ConnectionProfile response = + datastreamClient.updateConnectionProfileAsync(connectionProfile, updateMask).get(); + } + } +} +// [END +// datastream_v1_generated_datastreamclient_updateconnectionprofile_connectionprofilefieldmask_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStream.java new file mode 100644 index 000000000000..ac391b69f914 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updatestream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.UpdateStreamRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateStream { + + public static void main(String[] args) throws Exception { + asyncUpdateStream(); + } + + public static void asyncUpdateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateStreamRequest request = + UpdateStreamRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ApiFuture future = datastreamClient.updateStreamCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updatestream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java new file mode 100644 index 000000000000..dfaf286c6b59 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updatestream_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.OperationMetadata; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.UpdateStreamRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateStreamLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateStreamLRO(); + } + + public static void asyncUpdateStreamLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateStreamRequest request = + UpdateStreamRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.updateStreamOperationCallable().futureCall(request); + // Do something. + Stream response = future.get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updatestream_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStream.java new file mode 100644 index 000000000000..13b35c874a8b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStream.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updatestream_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Stream; +import com.google.cloud.datastream.v1.UpdateStreamRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateStream { + + public static void main(String[] args) throws Exception { + syncUpdateStream(); + } + + public static void syncUpdateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateStreamRequest request = + UpdateStreamRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + Stream response = datastreamClient.updateStreamAsync(request).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updatestream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.java new file mode 100644 index 000000000000..00f5dfd4d969 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamclient_updatestream_streamfieldmask_sync] +import com.google.cloud.datastream.v1.DatastreamClient; +import com.google.cloud.datastream.v1.Stream; +import com.google.protobuf.FieldMask; + +public class SyncUpdateStreamStreamFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateStreamStreamFieldmask(); + } + + public static void syncUpdateStreamStreamFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + Stream stream = Stream.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Stream response = datastreamClient.updateStreamAsync(stream, updateMask).get(); + } + } +} +// [END datastream_v1_generated_datastreamclient_updatestream_streamfieldmask_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.java new file mode 100644 index 000000000000..2f9eb9e85d32 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.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.datastream.v1.samples; + +// [START datastream_v1_generated_datastreamsettings_getconnectionprofile_sync] +import com.google.cloud.datastream.v1.DatastreamSettings; +import java.time.Duration; + +public class SyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfile(); + } + + public static void syncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DatastreamSettings.Builder datastreamSettingsBuilder = DatastreamSettings.newBuilder(); + datastreamSettingsBuilder + .getConnectionProfileSettings() + .setRetrySettings( + datastreamSettingsBuilder + .getConnectionProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DatastreamSettings datastreamSettings = datastreamSettingsBuilder.build(); + } +} +// [END datastream_v1_generated_datastreamsettings_getconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.java new file mode 100644 index 000000000000..9e86dfda8765 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.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.datastream.v1.stub.samples; + +// [START datastream_v1_generated_datastreamstubsettings_getconnectionprofile_sync] +import com.google.cloud.datastream.v1.stub.DatastreamStubSettings; +import java.time.Duration; + +public class SyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfile(); + } + + public static void syncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DatastreamStubSettings.Builder datastreamSettingsBuilder = DatastreamStubSettings.newBuilder(); + datastreamSettingsBuilder + .getConnectionProfileSettings() + .setRetrySettings( + datastreamSettingsBuilder + .getConnectionProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DatastreamStubSettings datastreamSettings = datastreamSettingsBuilder.build(); + } +} +// [END datastream_v1_generated_datastreamstubsettings_getconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetCredentialsProvider.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..154ec306da99 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DatastreamSettings; +import com.google.cloud.datastream.v1alpha1.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. + DatastreamSettings datastreamSettings = + DatastreamSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); + } +} +// [END datastream_v1alpha1_generated_datastreamclient_create_setcredentialsprovider_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetCredentialsProvider1.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..04dbdc70261e --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_create_setcredentialsprovider1_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DatastreamSettings; + +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. + DatastreamSettings datastreamSettings = + DatastreamSettings.newBuilder() + .setTransportChannelProvider( + DatastreamSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); + } +} +// [END datastream_v1alpha1_generated_datastreamclient_create_setcredentialsprovider1_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetEndpoint.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..a3d6a834519f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_create_setendpoint_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DatastreamSettings; +import com.google.cloud.datastream.v1alpha1.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. + DatastreamSettings datastreamSettings = + DatastreamSettings.newBuilder().setEndpoint(myEndpoint).build(); + DatastreamClient datastreamClient = DatastreamClient.create(datastreamSettings); + } +} +// [END datastream_v1alpha1_generated_datastreamclient_create_setendpoint_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.java new file mode 100644 index 000000000000..ec27fdb7cf43 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncCreateConnectionProfile(); + } + + public static void asyncCreateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateConnectionProfileRequest request = + CreateConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setConnectionProfileId("connectionProfileId597575526") + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + datastreamClient.createConnectionProfileCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.java new file mode 100644 index 000000000000..e4d95f53a830 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/AsyncCreateConnectionProfileLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; + +public class AsyncCreateConnectionProfileLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConnectionProfileLRO(); + } + + public static void asyncCreateConnectionProfileLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateConnectionProfileRequest request = + CreateConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setConnectionProfileId("connectionProfileId597575526") + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.createConnectionProfileOperationCallable().futureCall(request); + // Do something. + ConnectionProfile response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.java new file mode 100644 index 000000000000..4ce1011adc55 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.CreateConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncCreateConnectionProfile { + + public static void main(String[] args) throws Exception { + syncCreateConnectionProfile(); + } + + public static void syncCreateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateConnectionProfileRequest request = + CreateConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setConnectionProfileId("connectionProfileId597575526") + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ConnectionProfile response = datastreamClient.createConnectionProfileAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.java new file mode 100644 index 000000000000..8428a0f3ee78 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileLocationnameConnectionprofileString.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_locationnameconnectionprofilestring_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncCreateConnectionProfileLocationnameConnectionprofileString { + + public static void main(String[] args) throws Exception { + syncCreateConnectionProfileLocationnameConnectionprofileString(); + } + + public static void syncCreateConnectionProfileLocationnameConnectionprofileString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + ConnectionProfile response = + datastreamClient + .createConnectionProfileAsync(parent, connectionProfile, connectionProfileId) + .get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_locationnameconnectionprofilestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.java new file mode 100644 index 000000000000..9c9bed05fde1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createconnectionprofile/SyncCreateConnectionProfileStringConnectionprofileString.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_stringconnectionprofilestring_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncCreateConnectionProfileStringConnectionprofileString { + + public static void main(String[] args) throws Exception { + syncCreateConnectionProfileStringConnectionprofileString(); + } + + public static void syncCreateConnectionProfileStringConnectionprofileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + String connectionProfileId = "connectionProfileId597575526"; + ConnectionProfile response = + datastreamClient + .createConnectionProfileAsync(parent, connectionProfile, connectionProfileId) + .get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_createconnectionprofile_stringconnectionprofilestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.java new file mode 100644 index 000000000000..6890a35debdf --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnection.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createprivateconnection_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.longrunning.Operation; + +public class AsyncCreatePrivateConnection { + + public static void main(String[] args) throws Exception { + asyncCreatePrivateConnection(); + } + + public static void asyncCreatePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreatePrivateConnectionRequest request = + CreatePrivateConnectionRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPrivateConnectionId("privateConnectionId-1926654532") + .setPrivateConnection(PrivateConnection.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + datastreamClient.createPrivateConnectionCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createprivateconnection_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.java new file mode 100644 index 000000000000..02990337b97c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/AsyncCreatePrivateConnectionLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createprivateconnection_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class AsyncCreatePrivateConnectionLRO { + + public static void main(String[] args) throws Exception { + asyncCreatePrivateConnectionLRO(); + } + + public static void asyncCreatePrivateConnectionLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreatePrivateConnectionRequest request = + CreatePrivateConnectionRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPrivateConnectionId("privateConnectionId-1926654532") + .setPrivateConnection(PrivateConnection.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.createPrivateConnectionOperationCallable().futureCall(request); + // Do something. + PrivateConnection response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createprivateconnection_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.java new file mode 100644 index 000000000000..c5235abb1f7c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnection.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createprivateconnection_sync] +import com.google.cloud.datastream.v1alpha1.CreatePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class SyncCreatePrivateConnection { + + public static void main(String[] args) throws Exception { + syncCreatePrivateConnection(); + } + + public static void syncCreatePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreatePrivateConnectionRequest request = + CreatePrivateConnectionRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPrivateConnectionId("privateConnectionId-1926654532") + .setPrivateConnection(PrivateConnection.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + PrivateConnection response = datastreamClient.createPrivateConnectionAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createprivateconnection_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.java new file mode 100644 index 000000000000..75b5668dfd7e --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionLocationnamePrivateconnectionString.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_createprivateconnection_locationnameprivateconnectionstring_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class SyncCreatePrivateConnectionLocationnamePrivateconnectionString { + + public static void main(String[] args) throws Exception { + syncCreatePrivateConnectionLocationnamePrivateconnectionString(); + } + + public static void syncCreatePrivateConnectionLocationnamePrivateconnectionString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + PrivateConnection response = + datastreamClient + .createPrivateConnectionAsync(parent, privateConnection, privateConnectionId) + .get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_createprivateconnection_locationnameprivateconnectionstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.java new file mode 100644 index 000000000000..629cb8adb81c --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createprivateconnection/SyncCreatePrivateConnectionStringPrivateconnectionString.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_createprivateconnection_stringprivateconnectionstring_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class SyncCreatePrivateConnectionStringPrivateconnectionString { + + public static void main(String[] args) throws Exception { + syncCreatePrivateConnectionStringPrivateconnectionString(); + } + + public static void syncCreatePrivateConnectionStringPrivateconnectionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + PrivateConnection privateConnection = PrivateConnection.newBuilder().build(); + String privateConnectionId = "privateConnectionId-1926654532"; + PrivateConnection response = + datastreamClient + .createPrivateConnectionAsync(parent, privateConnection, privateConnectionId) + .get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_createprivateconnection_stringprivateconnectionstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRoute.java new file mode 100644 index 000000000000..1e6a07be988b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRoute.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createroute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.CreateRouteRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.longrunning.Operation; + +public class AsyncCreateRoute { + + public static void main(String[] args) throws Exception { + asyncCreateRoute(); + } + + public static void asyncCreateRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateRouteRequest request = + CreateRouteRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRouteId("routeId1385647428") + .setRoute(Route.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = datastreamClient.createRouteCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createroute_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRouteLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRouteLRO.java new file mode 100644 index 000000000000..fcb10e9d196e --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/AsyncCreateRouteLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createroute_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.CreateRouteRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class AsyncCreateRouteLRO { + + public static void main(String[] args) throws Exception { + asyncCreateRouteLRO(); + } + + public static void asyncCreateRouteLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateRouteRequest request = + CreateRouteRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRouteId("routeId1385647428") + .setRoute(Route.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.createRouteOperationCallable().futureCall(request); + // Do something. + Route response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createroute_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoute.java new file mode 100644 index 000000000000..012c1a6207aa --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoute.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createroute_sync] +import com.google.cloud.datastream.v1alpha1.CreateRouteRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class SyncCreateRoute { + + public static void main(String[] args) throws Exception { + syncCreateRoute(); + } + + public static void syncCreateRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateRouteRequest request = + CreateRouteRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRouteId("routeId1385647428") + .setRoute(Route.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + Route response = datastreamClient.createRouteAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createroute_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.java new file mode 100644 index 000000000000..7af1ee5ab076 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRoutePrivateconnectionnameRouteString.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_createroute_privateconnectionnameroutestring_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class SyncCreateRoutePrivateconnectionnameRouteString { + + public static void main(String[] args) throws Exception { + syncCreateRoutePrivateconnectionnameRouteString(); + } + + public static void syncCreateRoutePrivateconnectionnameRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + Route response = datastreamClient.createRouteAsync(parent, route, routeId).get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_createroute_privateconnectionnameroutestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRouteStringRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRouteStringRouteString.java new file mode 100644 index 000000000000..0f73a3370ecc --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createroute/SyncCreateRouteStringRouteString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createroute_stringroutestring_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class SyncCreateRouteStringRouteString { + + public static void main(String[] args) throws Exception { + syncCreateRouteStringRouteString(); + } + + public static void syncCreateRouteStringRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + Route route = Route.newBuilder().build(); + String routeId = "routeId1385647428"; + Route response = datastreamClient.createRouteAsync(parent, route, routeId).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createroute_stringroutestring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStream.java new file mode 100644 index 000000000000..a787d4efd7b9 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStream.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createstream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.CreateStreamRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.longrunning.Operation; + +public class AsyncCreateStream { + + public static void main(String[] args) throws Exception { + asyncCreateStream(); + } + + public static void asyncCreateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateStreamRequest request = + CreateStreamRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setStreamId("streamId1790933179") + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ApiFuture future = datastreamClient.createStreamCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createstream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStreamLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStreamLRO.java new file mode 100644 index 000000000000..78833470a097 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/AsyncCreateStreamLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createstream_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.CreateStreamRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class AsyncCreateStreamLRO { + + public static void main(String[] args) throws Exception { + asyncCreateStreamLRO(); + } + + public static void asyncCreateStreamLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateStreamRequest request = + CreateStreamRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setStreamId("streamId1790933179") + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.createStreamOperationCallable().futureCall(request); + // Do something. + Stream response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createstream_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStream.java new file mode 100644 index 000000000000..b84a3b176dbe --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createstream_sync] +import com.google.cloud.datastream.v1alpha1.CreateStreamRequest; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class SyncCreateStream { + + public static void main(String[] args) throws Exception { + syncCreateStream(); + } + + public static void syncCreateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + CreateStreamRequest request = + CreateStreamRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setStreamId("streamId1790933179") + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + Stream response = datastreamClient.createStreamAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createstream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.java new file mode 100644 index 000000000000..eeb716d5d33d --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamLocationnameStreamString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createstream_locationnamestreamstring_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class SyncCreateStreamLocationnameStreamString { + + public static void main(String[] args) throws Exception { + syncCreateStreamLocationnameStreamString(); + } + + public static void syncCreateStreamLocationnameStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + Stream response = datastreamClient.createStreamAsync(parent, stream, streamId).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createstream_locationnamestreamstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamStringStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamStringStreamString.java new file mode 100644 index 000000000000..00fbfea6cc16 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/createstream/SyncCreateStreamStringStreamString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_createstream_stringstreamstring_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class SyncCreateStreamStringStreamString { + + public static void main(String[] args) throws Exception { + syncCreateStreamStringStreamString(); + } + + public static void syncCreateStreamStringStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Stream stream = Stream.newBuilder().build(); + String streamId = "streamId1790933179"; + Stream response = datastreamClient.createStreamAsync(parent, stream, streamId).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_createstream_stringstreamstring_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.java new file mode 100644 index 000000000000..fc438bdb448f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteConnectionProfileRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectionProfile(); + } + + public static void asyncDeleteConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteConnectionProfileRequest request = + DeleteConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + datastreamClient.deleteConnectionProfileCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.java new file mode 100644 index 000000000000..6484b9fc49e1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/AsyncDeleteConnectionProfileLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteConnectionProfileLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectionProfileLRO(); + } + + public static void asyncDeleteConnectionProfileLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteConnectionProfileRequest request = + DeleteConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.deleteConnectionProfileOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.java new file mode 100644 index 000000000000..050e4b65a2d1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteConnectionProfileRequest; + +public class SyncDeleteConnectionProfile { + + public static void main(String[] args) throws Exception { + syncDeleteConnectionProfile(); + } + + public static void syncDeleteConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteConnectionProfileRequest request = + DeleteConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + datastreamClient.deleteConnectionProfileAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.java new file mode 100644 index 000000000000..597707838582 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileConnectionprofilename.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_connectionprofilename_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; + +public class SyncDeleteConnectionProfileConnectionprofilename { + + public static void main(String[] args) throws Exception { + syncDeleteConnectionProfileConnectionprofilename(); + } + + public static void syncDeleteConnectionProfileConnectionprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + datastreamClient.deleteConnectionProfileAsync(name).get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_connectionprofilename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.java new file mode 100644 index 000000000000..3779bf278888 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteconnectionprofile/SyncDeleteConnectionProfileString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_string_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; + +public class SyncDeleteConnectionProfileString { + + public static void main(String[] args) throws Exception { + syncDeleteConnectionProfileString(); + } + + public static void syncDeleteConnectionProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]").toString(); + datastreamClient.deleteConnectionProfileAsync(name).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteconnectionprofile_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.java new file mode 100644 index 000000000000..df006ec013b0 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnection.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.longrunning.Operation; + +public class AsyncDeletePrivateConnection { + + public static void main(String[] args) throws Exception { + asyncDeletePrivateConnection(); + } + + public static void asyncDeletePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeletePrivateConnectionRequest request = + DeletePrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + ApiFuture future = + datastreamClient.deletePrivateConnectionCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java new file mode 100644 index 000000000000..70c7d8ec8a46 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/AsyncDeletePrivateConnectionLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.protobuf.Empty; + +public class AsyncDeletePrivateConnectionLRO { + + public static void main(String[] args) throws Exception { + asyncDeletePrivateConnectionLRO(); + } + + public static void asyncDeletePrivateConnectionLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeletePrivateConnectionRequest request = + DeletePrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.deletePrivateConnectionOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.java new file mode 100644 index 000000000000..777c577eb838 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnection.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeletePrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class SyncDeletePrivateConnection { + + public static void main(String[] args) throws Exception { + syncDeletePrivateConnection(); + } + + public static void syncDeletePrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeletePrivateConnectionRequest request = + DeletePrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + datastreamClient.deletePrivateConnectionAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.java new file mode 100644 index 000000000000..e913623f95f9 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionPrivateconnectionname.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_privateconnectionname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class SyncDeletePrivateConnectionPrivateconnectionname { + + public static void main(String[] args) throws Exception { + syncDeletePrivateConnectionPrivateconnectionname(); + } + + public static void syncDeletePrivateConnectionPrivateconnectionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + datastreamClient.deletePrivateConnectionAsync(name).get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_privateconnectionname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.java new file mode 100644 index 000000000000..b2e0d57104fa --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteprivateconnection/SyncDeletePrivateConnectionString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class SyncDeletePrivateConnectionString { + + public static void main(String[] args) throws Exception { + syncDeletePrivateConnectionString(); + } + + public static void syncDeletePrivateConnectionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + datastreamClient.deletePrivateConnectionAsync(name).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteprivateconnection_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRoute.java new file mode 100644 index 000000000000..eb0c78367894 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRoute.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteroute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteRouteRequest; +import com.google.cloud.datastream.v1alpha1.RouteName; +import com.google.longrunning.Operation; + +public class AsyncDeleteRoute { + + public static void main(String[] args) throws Exception { + asyncDeleteRoute(); + } + + public static void asyncDeleteRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteRouteRequest request = + DeleteRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = datastreamClient.deleteRouteCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteroute_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.java new file mode 100644 index 000000000000..8d2e99559ca7 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/AsyncDeleteRouteLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteroute_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteRouteRequest; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.RouteName; +import com.google.protobuf.Empty; + +public class AsyncDeleteRouteLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteRouteLRO(); + } + + public static void asyncDeleteRouteLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteRouteRequest request = + DeleteRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.deleteRouteOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteroute_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRoute.java new file mode 100644 index 000000000000..eb15f13e2ddc --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRoute.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteroute_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteRouteRequest; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class SyncDeleteRoute { + + public static void main(String[] args) throws Exception { + syncDeleteRoute(); + } + + public static void syncDeleteRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteRouteRequest request = + DeleteRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .setRequestId("requestId693933066") + .build(); + datastreamClient.deleteRouteAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteroute_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.java new file mode 100644 index 000000000000..008a067359ac --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteRoutename.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteroute_routename_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class SyncDeleteRouteRoutename { + + public static void main(String[] args) throws Exception { + syncDeleteRouteRoutename(); + } + + public static void syncDeleteRouteRoutename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + datastreamClient.deleteRouteAsync(name).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteroute_routename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteString.java new file mode 100644 index 000000000000..2c0237dd2888 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deleteroute/SyncDeleteRouteString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deleteroute_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class SyncDeleteRouteString { + + public static void main(String[] args) throws Exception { + syncDeleteRouteString(); + } + + public static void syncDeleteRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]").toString(); + datastreamClient.deleteRouteAsync(name).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deleteroute_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStream.java new file mode 100644 index 000000000000..9ee548c64f9b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deletestream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteStreamRequest; +import com.google.cloud.datastream.v1alpha1.StreamName; +import com.google.longrunning.Operation; + +public class AsyncDeleteStream { + + public static void main(String[] args) throws Exception { + asyncDeleteStream(); + } + + public static void asyncDeleteStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteStreamRequest request = + DeleteStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = datastreamClient.deleteStreamCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deletestream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStreamLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStreamLRO.java new file mode 100644 index 000000000000..3f8214118b34 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/AsyncDeleteStreamLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deletestream_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteStreamRequest; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.StreamName; +import com.google.protobuf.Empty; + +public class AsyncDeleteStreamLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteStreamLRO(); + } + + public static void asyncDeleteStreamLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteStreamRequest request = + DeleteStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.deleteStreamOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deletestream_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStream.java new file mode 100644 index 000000000000..0a113f3f9bab --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deletestream_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DeleteStreamRequest; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncDeleteStream { + + public static void main(String[] args) throws Exception { + syncDeleteStream(); + } + + public static void syncDeleteStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DeleteStreamRequest request = + DeleteStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .setRequestId("requestId693933066") + .build(); + datastreamClient.deleteStreamAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deletestream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamStreamname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamStreamname.java new file mode 100644 index 000000000000..4793ce72825f --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamStreamname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deletestream_streamname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncDeleteStreamStreamname { + + public static void main(String[] args) throws Exception { + syncDeleteStreamStreamname(); + } + + public static void syncDeleteStreamStreamname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + datastreamClient.deleteStreamAsync(name).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deletestream_streamname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamString.java new file mode 100644 index 000000000000..c3a15b3c13f6 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/deletestream/SyncDeleteStreamString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_deletestream_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncDeleteStreamString { + + public static void main(String[] args) throws Exception { + syncDeleteStreamString(); + } + + public static void syncDeleteStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString(); + datastreamClient.deleteStreamAsync(name).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_deletestream_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.java new file mode 100644 index 000000000000..512417dfbaef --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/AsyncDiscoverConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_discoverconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DiscoverConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DiscoverConnectionProfileResponse; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class AsyncDiscoverConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncDiscoverConnectionProfile(); + } + + public static void asyncDiscoverConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + ApiFuture future = + datastreamClient.discoverConnectionProfileCallable().futureCall(request); + // Do something. + DiscoverConnectionProfileResponse response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_discoverconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.java new file mode 100644 index 000000000000..941258939048 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/discoverconnectionprofile/SyncDiscoverConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_discoverconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.DiscoverConnectionProfileRequest; +import com.google.cloud.datastream.v1alpha1.DiscoverConnectionProfileResponse; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncDiscoverConnectionProfile { + + public static void main(String[] args) throws Exception { + syncDiscoverConnectionProfile(); + } + + public static void syncDiscoverConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + DiscoverConnectionProfileRequest request = + DiscoverConnectionProfileRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + DiscoverConnectionProfileResponse response = + datastreamClient.discoverConnectionProfile(request); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_discoverconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrors.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrors.java new file mode 100644 index 000000000000..5db14c50c612 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrors.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetcherrors_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.FetchErrorsRequest; +import com.google.cloud.datastream.v1alpha1.StreamName; +import com.google.longrunning.Operation; + +public class AsyncFetchErrors { + + public static void main(String[] args) throws Exception { + asyncFetchErrors(); + } + + public static void asyncFetchErrors() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchErrorsRequest request = + FetchErrorsRequest.newBuilder() + .setStream(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + ApiFuture future = datastreamClient.fetchErrorsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetcherrors_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrorsLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrorsLRO.java new file mode 100644 index 000000000000..a072d0f14fe6 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/AsyncFetchErrorsLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetcherrors_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.FetchErrorsRequest; +import com.google.cloud.datastream.v1alpha1.FetchErrorsResponse; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class AsyncFetchErrorsLRO { + + public static void main(String[] args) throws Exception { + asyncFetchErrorsLRO(); + } + + public static void asyncFetchErrorsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchErrorsRequest request = + FetchErrorsRequest.newBuilder() + .setStream(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + OperationFuture future = + datastreamClient.fetchErrorsOperationCallable().futureCall(request); + // Do something. + FetchErrorsResponse response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetcherrors_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/SyncFetchErrors.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/SyncFetchErrors.java new file mode 100644 index 000000000000..b857ec592016 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetcherrors/SyncFetchErrors.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetcherrors_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.FetchErrorsRequest; +import com.google.cloud.datastream.v1alpha1.FetchErrorsResponse; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncFetchErrors { + + public static void main(String[] args) throws Exception { + syncFetchErrors(); + } + + public static void syncFetchErrors() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchErrorsRequest request = + FetchErrorsRequest.newBuilder() + .setStream(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + FetchErrorsResponse response = datastreamClient.fetchErrorsAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetcherrors_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.java new file mode 100644 index 000000000000..102c7dc016d8 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIps.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetchstaticips_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class AsyncFetchStaticIps { + + public static void main(String[] args) throws Exception { + asyncFetchStaticIps(); + } + + public static void asyncFetchStaticIps() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchStaticIpsRequest request = + FetchStaticIpsRequest.newBuilder() + .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = datastreamClient.fetchStaticIpsPagedCallable().futureCall(request); + // Do something. + for (String element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetchstaticips_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.java new file mode 100644 index 000000000000..987e3df11f06 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/AsyncFetchStaticIpsPaged.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetchstaticips_paged_async] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1alpha1.FetchStaticIpsResponse; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.common.base.Strings; + +public class AsyncFetchStaticIpsPaged { + + public static void main(String[] args) throws Exception { + asyncFetchStaticIpsPaged(); + } + + public static void asyncFetchStaticIpsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchStaticIpsRequest request = + FetchStaticIpsRequest.newBuilder() + .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + FetchStaticIpsResponse response = datastreamClient.fetchStaticIpsCallable().call(request); + for (String element : response.getStaticIpsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetchstaticips_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIps.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIps.java new file mode 100644 index 000000000000..c6c548d46ba1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIps.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetchstaticips_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.FetchStaticIpsRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncFetchStaticIps { + + public static void main(String[] args) throws Exception { + syncFetchStaticIps(); + } + + public static void syncFetchStaticIps() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + FetchStaticIpsRequest request = + FetchStaticIpsRequest.newBuilder() + .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (String element : datastreamClient.fetchStaticIps(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetchstaticips_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.java new file mode 100644 index 000000000000..40bd3c3c38e4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsLocationname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetchstaticips_locationname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncFetchStaticIpsLocationname { + + public static void main(String[] args) throws Exception { + syncFetchStaticIpsLocationname(); + } + + public static void syncFetchStaticIpsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName name = LocationName.of("[PROJECT]", "[LOCATION]"); + for (String element : datastreamClient.fetchStaticIps(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetchstaticips_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.java new file mode 100644 index 000000000000..3cd71199aac9 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/fetchstaticips/SyncFetchStaticIpsString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_fetchstaticips_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncFetchStaticIpsString { + + public static void main(String[] args) throws Exception { + syncFetchStaticIpsString(); + } + + public static void syncFetchStaticIpsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (String element : datastreamClient.fetchStaticIps(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_fetchstaticips_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.java new file mode 100644 index 000000000000..83d2546e1097 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/AsyncGetConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetConnectionProfileRequest; + +public class AsyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncGetConnectionProfile(); + } + + public static void asyncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetConnectionProfileRequest request = + GetConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .build(); + ApiFuture future = + datastreamClient.getConnectionProfileCallable().futureCall(request); + // Do something. + ConnectionProfile response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.java new file mode 100644 index 000000000000..55ecdc4996f3 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetConnectionProfileRequest; + +public class SyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfile(); + } + + public static void syncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetConnectionProfileRequest request = + GetConnectionProfileRequest.newBuilder() + .setName( + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]") + .toString()) + .build(); + ConnectionProfile response = datastreamClient.getConnectionProfile(request); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.java new file mode 100644 index 000000000000..030da00afbd1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileConnectionprofilename.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_connectionprofilename_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; + +public class SyncGetConnectionProfileConnectionprofilename { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfileConnectionprofilename(); + } + + public static void syncGetConnectionProfileConnectionprofilename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ConnectionProfileName name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); + ConnectionProfile response = datastreamClient.getConnectionProfile(name); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_connectionprofilename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.java new file mode 100644 index 000000000000..53d0981ae82e --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getconnectionprofile/SyncGetConnectionProfileString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_string_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.ConnectionProfileName; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; + +public class SyncGetConnectionProfileString { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfileString(); + } + + public static void syncGetConnectionProfileString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + ConnectionProfileName.of("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]").toString(); + ConnectionProfile response = datastreamClient.getConnectionProfile(name); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getconnectionprofile_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.java new file mode 100644 index 000000000000..e676f3937f3d --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/AsyncGetPrivateConnection.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getprivateconnection_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetPrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class AsyncGetPrivateConnection { + + public static void main(String[] args) throws Exception { + asyncGetPrivateConnection(); + } + + public static void asyncGetPrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetPrivateConnectionRequest request = + GetPrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .build(); + ApiFuture future = + datastreamClient.getPrivateConnectionCallable().futureCall(request); + // Do something. + PrivateConnection response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getprivateconnection_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.java new file mode 100644 index 000000000000..517d136c5fd0 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnection.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getprivateconnection_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetPrivateConnectionRequest; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class SyncGetPrivateConnection { + + public static void main(String[] args) throws Exception { + syncGetPrivateConnection(); + } + + public static void syncGetPrivateConnection() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetPrivateConnectionRequest request = + GetPrivateConnectionRequest.newBuilder() + .setName( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .build(); + PrivateConnection response = datastreamClient.getPrivateConnection(request); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getprivateconnection_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.java new file mode 100644 index 000000000000..664c7cabb258 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionPrivateconnectionname.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_getprivateconnection_privateconnectionname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class SyncGetPrivateConnectionPrivateconnectionname { + + public static void main(String[] args) throws Exception { + syncGetPrivateConnectionPrivateconnectionname(); + } + + public static void syncGetPrivateConnectionPrivateconnectionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + PrivateConnection response = datastreamClient.getPrivateConnection(name); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_getprivateconnection_privateconnectionname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.java new file mode 100644 index 000000000000..3c5dc0fa4dd4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getprivateconnection/SyncGetPrivateConnectionString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getprivateconnection_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; + +public class SyncGetPrivateConnectionString { + + public static void main(String[] args) throws Exception { + syncGetPrivateConnectionString(); + } + + public static void syncGetPrivateConnectionString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + PrivateConnection response = datastreamClient.getPrivateConnection(name); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getprivateconnection_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/AsyncGetRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/AsyncGetRoute.java new file mode 100644 index 000000000000..8c4be667e2eb --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/AsyncGetRoute.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getroute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetRouteRequest; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class AsyncGetRoute { + + public static void main(String[] args) throws Exception { + asyncGetRoute(); + } + + public static void asyncGetRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetRouteRequest request = + GetRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .build(); + ApiFuture future = datastreamClient.getRouteCallable().futureCall(request); + // Do something. + Route response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getroute_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRoute.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRoute.java new file mode 100644 index 000000000000..33a59dad8489 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRoute.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getroute_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetRouteRequest; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class SyncGetRoute { + + public static void main(String[] args) throws Exception { + syncGetRoute(); + } + + public static void syncGetRoute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetRouteRequest request = + GetRouteRequest.newBuilder() + .setName( + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]") + .toString()) + .build(); + Route response = datastreamClient.getRoute(request); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getroute_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteRoutename.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteRoutename.java new file mode 100644 index 000000000000..4262e81c2946 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteRoutename.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getroute_routename_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class SyncGetRouteRoutename { + + public static void main(String[] args) throws Exception { + syncGetRouteRoutename(); + } + + public static void syncGetRouteRoutename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + RouteName name = RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]"); + Route response = datastreamClient.getRoute(name); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getroute_routename_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteString.java new file mode 100644 index 000000000000..78329ed0e07b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getroute/SyncGetRouteString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getroute_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.cloud.datastream.v1alpha1.RouteName; + +public class SyncGetRouteString { + + public static void main(String[] args) throws Exception { + syncGetRouteString(); + } + + public static void syncGetRouteString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = + RouteName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]", "[ROUTE]").toString(); + Route response = datastreamClient.getRoute(name); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getroute_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/AsyncGetStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/AsyncGetStream.java new file mode 100644 index 000000000000..6fe8931295bd --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/AsyncGetStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getstream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetStreamRequest; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class AsyncGetStream { + + public static void main(String[] args) throws Exception { + asyncGetStream(); + } + + public static void asyncGetStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetStreamRequest request = + GetStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + ApiFuture future = datastreamClient.getStreamCallable().futureCall(request); + // Do something. + Stream response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getstream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStream.java new file mode 100644 index 000000000000..d1f9b4c1a860 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getstream_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.GetStreamRequest; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncGetStream { + + public static void main(String[] args) throws Exception { + syncGetStream(); + } + + public static void syncGetStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + GetStreamRequest request = + GetStreamRequest.newBuilder() + .setName(StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString()) + .build(); + Stream response = datastreamClient.getStream(request); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getstream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamStreamname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamStreamname.java new file mode 100644 index 000000000000..e78922302c27 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamStreamname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getstream_streamname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncGetStreamStreamname { + + public static void main(String[] args) throws Exception { + syncGetStreamStreamname(); + } + + public static void syncGetStreamStreamname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + StreamName name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]"); + Stream response = datastreamClient.getStream(name); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getstream_streamname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamString.java new file mode 100644 index 000000000000..b57272a03b3e --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/getstream/SyncGetStreamString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_getstream_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.StreamName; + +public class SyncGetStreamString { + + public static void main(String[] args) throws Exception { + syncGetStreamString(); + } + + public static void syncGetStreamString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String name = StreamName.of("[PROJECT]", "[LOCATION]", "[STREAM]").toString(); + Stream response = datastreamClient.getStream(name); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_getstream_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java new file mode 100644 index 000000000000..c518319fcbd9 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfiles.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class AsyncListConnectionProfiles { + + public static void main(String[] args) throws Exception { + asyncListConnectionProfiles(); + } + + public static void asyncListConnectionProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListConnectionProfilesRequest request = + ListConnectionProfilesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + datastreamClient.listConnectionProfilesPagedCallable().futureCall(request); + // Do something. + for (ConnectionProfile element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java new file mode 100644 index 000000000000..a5b205e72459 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/AsyncListConnectionProfilesPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_paged_async] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1alpha1.ListConnectionProfilesResponse; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListConnectionProfilesPaged { + + public static void main(String[] args) throws Exception { + asyncListConnectionProfilesPaged(); + } + + public static void asyncListConnectionProfilesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListConnectionProfilesRequest request = + ListConnectionProfilesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListConnectionProfilesResponse response = + datastreamClient.listConnectionProfilesCallable().call(request); + for (ConnectionProfile element : response.getConnectionProfilesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.java new file mode 100644 index 000000000000..b09d38ff21e4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfiles.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListConnectionProfilesRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncListConnectionProfiles { + + public static void main(String[] args) throws Exception { + syncListConnectionProfiles(); + } + + public static void syncListConnectionProfiles() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListConnectionProfilesRequest request = + ListConnectionProfilesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (ConnectionProfile element : + datastreamClient.listConnectionProfiles(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.java new file mode 100644 index 000000000000..e239e6d7a9c4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesLocationname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_locationname_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncListConnectionProfilesLocationname { + + public static void main(String[] args) throws Exception { + syncListConnectionProfilesLocationname(); + } + + public static void syncListConnectionProfilesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (ConnectionProfile element : + datastreamClient.listConnectionProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.java new file mode 100644 index 000000000000..8ff8cdd13c87 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listconnectionprofiles/SyncListConnectionProfilesString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_string_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; + +public class SyncListConnectionProfilesString { + + public static void main(String[] args) throws Exception { + syncListConnectionProfilesString(); + } + + public static void syncListConnectionProfilesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (ConnectionProfile element : + datastreamClient.listConnectionProfiles(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listconnectionprofiles_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java new file mode 100644 index 000000000000..fbb140c32165 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnections.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listprivateconnections_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class AsyncListPrivateConnections { + + public static void main(String[] args) throws Exception { + asyncListPrivateConnections(); + } + + public static void asyncListPrivateConnections() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListPrivateConnectionsRequest request = + ListPrivateConnectionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + datastreamClient.listPrivateConnectionsPagedCallable().futureCall(request); + // Do something. + for (PrivateConnection element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listprivateconnections_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java new file mode 100644 index 000000000000..2aa1535bd7ae --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/AsyncListPrivateConnectionsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listprivateconnections_paged_async] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1alpha1.ListPrivateConnectionsResponse; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; +import com.google.common.base.Strings; + +public class AsyncListPrivateConnectionsPaged { + + public static void main(String[] args) throws Exception { + asyncListPrivateConnectionsPaged(); + } + + public static void asyncListPrivateConnectionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListPrivateConnectionsRequest request = + ListPrivateConnectionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListPrivateConnectionsResponse response = + datastreamClient.listPrivateConnectionsCallable().call(request); + for (PrivateConnection element : response.getPrivateConnectionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listprivateconnections_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnections.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnections.java new file mode 100644 index 000000000000..28591e76a4c1 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnections.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listprivateconnections_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListPrivateConnectionsRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class SyncListPrivateConnections { + + public static void main(String[] args) throws Exception { + syncListPrivateConnections(); + } + + public static void syncListPrivateConnections() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListPrivateConnectionsRequest request = + ListPrivateConnectionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (PrivateConnection element : + datastreamClient.listPrivateConnections(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listprivateconnections_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.java new file mode 100644 index 000000000000..557830f53f29 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsLocationname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listprivateconnections_locationname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class SyncListPrivateConnectionsLocationname { + + public static void main(String[] args) throws Exception { + syncListPrivateConnectionsLocationname(); + } + + public static void syncListPrivateConnectionsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (PrivateConnection element : + datastreamClient.listPrivateConnections(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listprivateconnections_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.java new file mode 100644 index 000000000000..57ef891fbe79 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listprivateconnections/SyncListPrivateConnectionsString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listprivateconnections_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.PrivateConnection; + +public class SyncListPrivateConnectionsString { + + public static void main(String[] args) throws Exception { + syncListPrivateConnectionsString(); + } + + public static void syncListPrivateConnectionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (PrivateConnection element : + datastreamClient.listPrivateConnections(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listprivateconnections_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutes.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutes.java new file mode 100644 index 000000000000..588a1d0f85a9 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutes.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listroutes_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListRoutesRequest; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class AsyncListRoutes { + + public static void main(String[] args) throws Exception { + asyncListRoutes(); + } + + public static void asyncListRoutes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListRoutesRequest request = + ListRoutesRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = datastreamClient.listRoutesPagedCallable().futureCall(request); + // Do something. + for (Route element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listroutes_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutesPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutesPaged.java new file mode 100644 index 000000000000..b33b990fbd6e --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/AsyncListRoutesPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listroutes_paged_async] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListRoutesRequest; +import com.google.cloud.datastream.v1alpha1.ListRoutesResponse; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; +import com.google.common.base.Strings; + +public class AsyncListRoutesPaged { + + public static void main(String[] args) throws Exception { + asyncListRoutesPaged(); + } + + public static void asyncListRoutesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListRoutesRequest request = + ListRoutesRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListRoutesResponse response = datastreamClient.listRoutesCallable().call(request); + for (Route element : response.getRoutesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listroutes_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutes.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutes.java new file mode 100644 index 000000000000..0fd289cfbc91 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutes.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listroutes_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListRoutesRequest; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class SyncListRoutes { + + public static void main(String[] args) throws Exception { + syncListRoutes(); + } + + public static void syncListRoutes() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListRoutesRequest request = + ListRoutesRequest.newBuilder() + .setParent( + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Route element : datastreamClient.listRoutes(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listroutes_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.java new file mode 100644 index 000000000000..c43e408b816a --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesPrivateconnectionname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listroutes_privateconnectionname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class SyncListRoutesPrivateconnectionname { + + public static void main(String[] args) throws Exception { + syncListRoutesPrivateconnectionname(); + } + + public static void syncListRoutesPrivateconnectionname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + PrivateConnectionName parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]"); + for (Route element : datastreamClient.listRoutes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listroutes_privateconnectionname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesString.java new file mode 100644 index 000000000000..7306f84d8e2b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/listroutes/SyncListRoutesString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_listroutes_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.PrivateConnectionName; +import com.google.cloud.datastream.v1alpha1.Route; + +public class SyncListRoutesString { + + public static void main(String[] args) throws Exception { + syncListRoutesString(); + } + + public static void syncListRoutesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = + PrivateConnectionName.of("[PROJECT]", "[LOCATION]", "[PRIVATE_CONNECTION]").toString(); + for (Route element : datastreamClient.listRoutes(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_listroutes_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreams.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreams.java new file mode 100644 index 000000000000..9fbd60f10981 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreams.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_liststreams_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListStreamsRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class AsyncListStreams { + + public static void main(String[] args) throws Exception { + asyncListStreams(); + } + + public static void asyncListStreams() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamsRequest request = + ListStreamsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = datastreamClient.listStreamsPagedCallable().futureCall(request); + // Do something. + for (Stream element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_liststreams_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreamsPaged.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreamsPaged.java new file mode 100644 index 000000000000..fd13d3c5b460 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/AsyncListStreamsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_liststreams_paged_async] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListStreamsRequest; +import com.google.cloud.datastream.v1alpha1.ListStreamsResponse; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.common.base.Strings; + +public class AsyncListStreamsPaged { + + public static void main(String[] args) throws Exception { + asyncListStreamsPaged(); + } + + public static void asyncListStreamsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamsRequest request = + ListStreamsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListStreamsResponse response = datastreamClient.listStreamsCallable().call(request); + for (Stream element : response.getStreamsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_liststreams_paged_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreams.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreams.java new file mode 100644 index 000000000000..6d95caf3fc30 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreams.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_liststreams_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.ListStreamsRequest; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class SyncListStreams { + + public static void main(String[] args) throws Exception { + syncListStreams(); + } + + public static void syncListStreams() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ListStreamsRequest request = + ListStreamsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Stream element : datastreamClient.listStreams(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_liststreams_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsLocationname.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsLocationname.java new file mode 100644 index 000000000000..3c547b484995 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsLocationname.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_liststreams_locationname_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class SyncListStreamsLocationname { + + public static void main(String[] args) throws Exception { + syncListStreamsLocationname(); + } + + public static void syncListStreamsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Stream element : datastreamClient.listStreams(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_liststreams_locationname_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsString.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsString.java new file mode 100644 index 000000000000..273bd71d0571 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/liststreams/SyncListStreamsString.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_liststreams_string_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.LocationName; +import com.google.cloud.datastream.v1alpha1.Stream; + +public class SyncListStreamsString { + + public static void main(String[] args) throws Exception { + syncListStreamsString(); + } + + public static void syncListStreamsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Stream element : datastreamClient.listStreams(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_liststreams_string_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.java new file mode 100644 index 000000000000..de42de78a30b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.UpdateConnectionProfileRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectionProfile { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectionProfile(); + } + + public static void asyncUpdateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateConnectionProfileRequest request = + UpdateConnectionProfileRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + datastreamClient.updateConnectionProfileCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.java new file mode 100644 index 000000000000..0dfdd204fd81 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/AsyncUpdateConnectionProfileLRO.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.UpdateConnectionProfileRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectionProfileLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectionProfileLRO(); + } + + public static void asyncUpdateConnectionProfileLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateConnectionProfileRequest request = + UpdateConnectionProfileRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + datastreamClient.updateConnectionProfileOperationCallable().futureCall(request); + // Do something. + ConnectionProfile response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.java new file mode 100644 index 000000000000..3b0fb0c4119b --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.UpdateConnectionProfileRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectionProfile { + + public static void main(String[] args) throws Exception { + syncUpdateConnectionProfile(); + } + + public static void syncUpdateConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateConnectionProfileRequest request = + UpdateConnectionProfileRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setConnectionProfile(ConnectionProfile.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ConnectionProfile response = datastreamClient.updateConnectionProfileAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.java new file mode 100644 index 000000000000..c77232f961aa --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updateconnectionprofile/SyncUpdateConnectionProfileConnectionprofileFieldmask.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.datastream.v1alpha1.samples; + +// [START +// datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_connectionprofilefieldmask_sync] +import com.google.cloud.datastream.v1alpha1.ConnectionProfile; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectionProfileConnectionprofileFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateConnectionProfileConnectionprofileFieldmask(); + } + + public static void syncUpdateConnectionProfileConnectionprofileFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + ConnectionProfile connectionProfile = ConnectionProfile.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ConnectionProfile response = + datastreamClient.updateConnectionProfileAsync(connectionProfile, updateMask).get(); + } + } +} +// [END +// datastream_v1alpha1_generated_datastreamclient_updateconnectionprofile_connectionprofilefieldmask_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStream.java new file mode 100644 index 000000000000..ff02b15fae77 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updatestream_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.UpdateStreamRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateStream { + + public static void main(String[] args) throws Exception { + asyncUpdateStream(); + } + + public static void asyncUpdateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateStreamRequest request = + UpdateStreamRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + ApiFuture future = datastreamClient.updateStreamCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updatestream_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java new file mode 100644 index 000000000000..6554853a98a5 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/AsyncUpdateStreamLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updatestream_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.OperationMetadata; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.UpdateStreamRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateStreamLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateStreamLRO(); + } + + public static void asyncUpdateStreamLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateStreamRequest request = + UpdateStreamRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + OperationFuture future = + datastreamClient.updateStreamOperationCallable().futureCall(request); + // Do something. + Stream response = future.get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updatestream_lro_async] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStream.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStream.java new file mode 100644 index 000000000000..109b116c73b4 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStream.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updatestream_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.cloud.datastream.v1alpha1.UpdateStreamRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateStream { + + public static void main(String[] args) throws Exception { + syncUpdateStream(); + } + + public static void syncUpdateStream() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + UpdateStreamRequest request = + UpdateStreamRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setStream(Stream.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .setForce(true) + .build(); + Stream response = datastreamClient.updateStreamAsync(request).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updatestream_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.java new file mode 100644 index 000000000000..4c5a320d02f8 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamclient/updatestream/SyncUpdateStreamStreamFieldmask.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamclient_updatestream_streamfieldmask_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamClient; +import com.google.cloud.datastream.v1alpha1.Stream; +import com.google.protobuf.FieldMask; + +public class SyncUpdateStreamStreamFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateStreamStreamFieldmask(); + } + + public static void syncUpdateStreamStreamFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DatastreamClient datastreamClient = DatastreamClient.create()) { + Stream stream = Stream.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Stream response = datastreamClient.updateStreamAsync(stream, updateMask).get(); + } + } +} +// [END datastream_v1alpha1_generated_datastreamclient_updatestream_streamfieldmask_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.java new file mode 100644 index 000000000000..023ff5324310 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/datastreamsettings/getconnectionprofile/SyncGetConnectionProfile.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.datastream.v1alpha1.samples; + +// [START datastream_v1alpha1_generated_datastreamsettings_getconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.DatastreamSettings; +import java.time.Duration; + +public class SyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfile(); + } + + public static void syncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DatastreamSettings.Builder datastreamSettingsBuilder = DatastreamSettings.newBuilder(); + datastreamSettingsBuilder + .getConnectionProfileSettings() + .setRetrySettings( + datastreamSettingsBuilder + .getConnectionProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DatastreamSettings datastreamSettings = datastreamSettingsBuilder.build(); + } +} +// [END datastream_v1alpha1_generated_datastreamsettings_getconnectionprofile_sync] diff --git a/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.java b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.java new file mode 100644 index 000000000000..a1ec0dc7c9a3 --- /dev/null +++ b/java-datastream/samples/snippets/generated/com/google/cloud/datastream/v1alpha1/stub/datastreamstubsettings/getconnectionprofile/SyncGetConnectionProfile.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.datastream.v1alpha1.stub.samples; + +// [START datastream_v1alpha1_generated_datastreamstubsettings_getconnectionprofile_sync] +import com.google.cloud.datastream.v1alpha1.stub.DatastreamStubSettings; +import java.time.Duration; + +public class SyncGetConnectionProfile { + + public static void main(String[] args) throws Exception { + syncGetConnectionProfile(); + } + + public static void syncGetConnectionProfile() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DatastreamStubSettings.Builder datastreamSettingsBuilder = DatastreamStubSettings.newBuilder(); + datastreamSettingsBuilder + .getConnectionProfileSettings() + .setRetrySettings( + datastreamSettingsBuilder + .getConnectionProfileSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DatastreamStubSettings datastreamSettings = datastreamSettingsBuilder.build(); + } +} +// [END datastream_v1alpha1_generated_datastreamstubsettings_getconnectionprofile_sync]