|
| 1 | +// Copyright 2019 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 BIGQUERY_CLIENT_H_ |
| 16 | +#define BIGQUERY_CLIENT_H_ |
| 17 | + |
| 18 | +#include <memory> |
| 19 | + |
| 20 | +#include "google/cloud/bigquery/connection.h" |
| 21 | +#include "google/cloud/bigquery/connection_options.h" |
| 22 | +#include "google/cloud/bigquery/version.h" |
| 23 | +#include "google/cloud/status_or.h" |
| 24 | + |
| 25 | +namespace google { |
| 26 | +namespace cloud { |
| 27 | +namespace bigquery { |
| 28 | +inline namespace BIGQUERY_CLIENT_NS { |
| 29 | +class Client { |
| 30 | + public: |
| 31 | + explicit Client(std::shared_ptr<Connection> conn) : conn_(std::move(conn)) {} |
| 32 | + |
| 33 | + Client() = delete; |
| 34 | + |
| 35 | + // Client is copyable and movable. |
| 36 | + Client(Client const&) = default; |
| 37 | + Client& operator=(Client const&) = default; |
| 38 | + Client(Client&&) = default; |
| 39 | + Client& operator=(Client&&) = default; |
| 40 | + |
| 41 | + friend bool operator==(Client const& a, Client const& b) { |
| 42 | + return a.conn_ == b.conn_; |
| 43 | + } |
| 44 | + |
| 45 | + friend bool operator!=(Client const& a, Client const& b) { return !(a == b); } |
| 46 | + |
| 47 | + // Creates a new read session and returns its name if successful. |
| 48 | + // |
| 49 | + // This function is just a proof of concept to ensure we can send |
| 50 | + // requests to the server. |
| 51 | + google::cloud::StatusOr<std::string> CreateSession( |
| 52 | + std::string parent_project_id, std::string table); |
| 53 | + |
| 54 | + private: |
| 55 | + std::shared_ptr<Connection> conn_; |
| 56 | +}; |
| 57 | + |
| 58 | +std::shared_ptr<Connection> MakeConnection(ConnectionOptions const& options); |
| 59 | + |
| 60 | +} // namespace BIGQUERY_CLIENT_NS |
| 61 | +} // namespace bigquery |
| 62 | +} // namespace cloud |
| 63 | +} // namespace google |
| 64 | + |
| 65 | +#endif // BIGQUERY_CLIENT_H_ |
0 commit comments