Google Cloud Pub/Sub C++ Client  1.33.0
A C++ Client Library for Google Cloud Pub/Sub
schema_metadata.h
Go to the documentation of this file.
1 // Copyright 2021 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SCHEMA_METADATA_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SCHEMA_METADATA_H
17 
18 #include "google/cloud/pubsub/internal/schema_stub.h"
19 #include "google/cloud/pubsub/version.h"
20 #include <memory>
21 #include <string>
22 
23 namespace google {
24 namespace cloud {
25 namespace pubsub_internal {
27 
28 /**
29  * A Decorator for `SchemaStub` that logs each request and response.
30  */
31 class SchemaMetadata : public SchemaStub {
32  public:
33  explicit SchemaMetadata(std::shared_ptr<SchemaStub> child);
34 
35  StatusOr<google::pubsub::v1::Schema> CreateSchema(
36  grpc::ClientContext& context,
37  google::pubsub::v1::CreateSchemaRequest const& request) override;
38  StatusOr<google::pubsub::v1::Schema> GetSchema(
39  grpc::ClientContext& context,
40  google::pubsub::v1::GetSchemaRequest const& request) override;
41  StatusOr<google::pubsub::v1::ListSchemasResponse> ListSchemas(
42  grpc::ClientContext& context,
43  google::pubsub::v1::ListSchemasRequest const& request) override;
44  Status DeleteSchema(
45  grpc::ClientContext& context,
46  google::pubsub::v1::DeleteSchemaRequest const& request) override;
47  StatusOr<google::pubsub::v1::ValidateSchemaResponse> ValidateSchema(
48  grpc::ClientContext& context,
49  google::pubsub::v1::ValidateSchemaRequest const& request) override;
50  StatusOr<google::pubsub::v1::ValidateMessageResponse> ValidateMessage(
51  grpc::ClientContext& context,
52  google::pubsub::v1::ValidateMessageRequest const& request) override;
53 
54  private:
55  void SetMetadata(grpc::ClientContext& context,
56  std::string const& request_params);
57 
58  std::shared_ptr<SchemaStub> child_;
59  std::string x_goog_api_client_;
60 };
61 
63 } // namespace pubsub_internal
64 } // namespace cloud
65 } // namespace google
66 
67 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SCHEMA_METADATA_H