Skip to content

Commit 9d62df7

Browse files
authored
impl(storage): add AsyncDeleteObject() to stubs (#9115)
1 parent 022f941 commit 9d62df7

13 files changed

+121
-0
lines changed

generator/generator_config.textproto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ service {
11901190
omit_connection: true
11911191
omit_stub_factory: true
11921192
gen_async_rpcs: [
1193+
"DeleteObject",
11931194
"ReadObject"
11941195
]
11951196
omitted_rpcs: [

google/cloud/storage/internal/storage_auth_decorator.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ StatusOr<google::storage::v2::HmacKeyMetadata> StorageAuth::UpdateHmacKey(
241241
return child_->UpdateHmacKey(context, request);
242242
}
243243

244+
future<Status> StorageAuth::AsyncDeleteObject(
245+
google::cloud::CompletionQueue& cq,
246+
std::unique_ptr<grpc::ClientContext> context,
247+
google::storage::v2::DeleteObjectRequest const& request) {
248+
auto child = child_;
249+
return auth_->AsyncConfigureContext(std::move(context))
250+
.then([cq, child,
251+
request](future<StatusOr<std::unique_ptr<grpc::ClientContext>>>
252+
f) mutable {
253+
auto context = f.get();
254+
if (!context) return make_ready_future(std::move(context).status());
255+
return child->AsyncDeleteObject(cq, *std::move(context), request);
256+
});
257+
}
258+
244259
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
245260
google::storage::v2::ReadObjectResponse>>
246261
StorageAuth::AsyncReadObject(

google/cloud/storage/internal/storage_auth_decorator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ class StorageAuth : public StorageStub {
142142
grpc::ClientContext& context,
143143
google::storage::v2::UpdateHmacKeyRequest const& request) override;
144144

145+
future<Status> AsyncDeleteObject(
146+
google::cloud::CompletionQueue& cq,
147+
std::unique_ptr<grpc::ClientContext> context,
148+
google::storage::v2::DeleteObjectRequest const& request) override;
149+
145150
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
146151
google::storage::v2::ReadObjectResponse>>
147152
AsyncReadObject(

google/cloud/storage/internal/storage_logging_decorator.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,19 @@ StatusOr<google::storage::v2::HmacKeyMetadata> StorageLogging::UpdateHmacKey(
337337
context, request, __func__, tracing_options_);
338338
}
339339

340+
future<Status> StorageLogging::AsyncDeleteObject(
341+
google::cloud::CompletionQueue& cq,
342+
std::unique_ptr<grpc::ClientContext> context,
343+
google::storage::v2::DeleteObjectRequest const& request) {
344+
return google::cloud::internal::LogWrapper(
345+
[this](google::cloud::CompletionQueue& cq,
346+
std::unique_ptr<grpc::ClientContext> context,
347+
google::storage::v2::DeleteObjectRequest const& request) {
348+
return child_->AsyncDeleteObject(cq, std::move(context), request);
349+
},
350+
cq, std::move(context), request, __func__, tracing_options_);
351+
}
352+
340353
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
341354
google::storage::v2::ReadObjectResponse>>
342355
StorageLogging::AsyncReadObject(

google/cloud/storage/internal/storage_logging_decorator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ class StorageLogging : public StorageStub {
142142
grpc::ClientContext& context,
143143
google::storage::v2::UpdateHmacKeyRequest const& request) override;
144144

145+
future<Status> AsyncDeleteObject(
146+
google::cloud::CompletionQueue& cq,
147+
std::unique_ptr<grpc::ClientContext> context,
148+
google::storage::v2::DeleteObjectRequest const& request) override;
149+
145150
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
146151
google::storage::v2::ReadObjectResponse>>
147152
AsyncReadObject(

google/cloud/storage/internal/storage_metadata_decorator.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ StatusOr<google::storage::v2::HmacKeyMetadata> StorageMetadata::UpdateHmacKey(
218218
return child_->UpdateHmacKey(context, request);
219219
}
220220

221+
future<Status> StorageMetadata::AsyncDeleteObject(
222+
google::cloud::CompletionQueue& cq,
223+
std::unique_ptr<grpc::ClientContext> context,
224+
google::storage::v2::DeleteObjectRequest const& request) {
225+
SetMetadata(*context);
226+
return child_->AsyncDeleteObject(cq, std::move(context), request);
227+
}
228+
221229
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
222230
google::storage::v2::ReadObjectResponse>>
223231
StorageMetadata::AsyncReadObject(

google/cloud/storage/internal/storage_metadata_decorator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ class StorageMetadata : public StorageStub {
138138
grpc::ClientContext& context,
139139
google::storage::v2::UpdateHmacKeyRequest const& request) override;
140140

141+
future<Status> AsyncDeleteObject(
142+
google::cloud::CompletionQueue& cq,
143+
std::unique_ptr<grpc::ClientContext> context,
144+
google::storage::v2::DeleteObjectRequest const& request) override;
145+
141146
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
142147
google::storage::v2::ReadObjectResponse>>
143148
AsyncReadObject(

google/cloud/storage/internal/storage_round_robin.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ StatusOr<google::storage::v2::HmacKeyMetadata> StorageRoundRobin::UpdateHmacKey(
181181
return Child()->UpdateHmacKey(context, request);
182182
}
183183

184+
future<Status> StorageRoundRobin::AsyncDeleteObject(
185+
google::cloud::CompletionQueue& cq,
186+
std::unique_ptr<grpc::ClientContext> context,
187+
google::storage::v2::DeleteObjectRequest const& request) {
188+
return Child()->AsyncDeleteObject(cq, std::move(context), request);
189+
}
190+
184191
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
185192
google::storage::v2::ReadObjectResponse>>
186193
StorageRoundRobin::AsyncReadObject(

google/cloud/storage/internal/storage_round_robin.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ class StorageRoundRobin : public StorageStub {
134134
grpc::ClientContext& context,
135135
google::storage::v2::UpdateHmacKeyRequest const& request) override;
136136

137+
future<Status> AsyncDeleteObject(
138+
google::cloud::CompletionQueue& cq,
139+
std::unique_ptr<grpc::ClientContext> context,
140+
google::storage::v2::DeleteObjectRequest const& request) override;
141+
137142
std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
138143
google::storage::v2::ReadObjectResponse>>
139144
AsyncReadObject(

google/cloud/storage/internal/storage_round_robin_test.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace {
2727

2828
using ::google::cloud::storage::testing::MockStorageStub;
2929
using ::google::cloud::testing_util::StatusIs;
30+
using ::testing::ByMove;
3031
using ::testing::InSequence;
3132
using ::testing::Return;
3233

@@ -557,6 +558,30 @@ TEST(StorageRoundRobinTest, UpdateHmacKey) {
557558
}
558559
}
559560

561+
TEST(StorageRoundRobinTest, AsyncDeleteObject) {
562+
auto mocks = MakeMocks();
563+
InSequence sequence;
564+
for (int i = 0; i != kRepeats; ++i) {
565+
for (auto& m : mocks) {
566+
EXPECT_CALL(*m, AsyncDeleteObject)
567+
.WillOnce(Return(ByMove(make_ready_future(
568+
Status(StatusCode::kPermissionDenied, "uh-oh")))));
569+
}
570+
}
571+
572+
StorageRoundRobin under_test(AsPlainStubs(mocks));
573+
google::cloud::CompletionQueue cq;
574+
for (size_t i = 0; i != kRepeats * mocks.size(); ++i) {
575+
google::storage::v2::DeleteObjectRequest request;
576+
auto response =
577+
under_test
578+
.AsyncDeleteObject(cq, absl::make_unique<grpc::ClientContext>(),
579+
request)
580+
.get();
581+
EXPECT_THAT(response, StatusIs(StatusCode::kPermissionDenied));
582+
}
583+
}
584+
560585
TEST(StorageRoundRobinTest, AsyncReadObject) {
561586
auto mocks = MakeMocks();
562587
InSequence sequence;

0 commit comments

Comments
 (0)