Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kms): support the EKM service #8530

Merged
merged 3 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ https://github.com/googleapis/google-cloud-cpp/issues/8234.

## v1.39.0 - TBD

### [KMS](https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/kms/README.md)

The library has been expanded to include the following services:

* [External Key Manager](https://cloud.google.com/kms/docs/ekm)

## v1.38.0 - 2022-03

### [Service Management API](https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/servicemanagement/README.md)
Expand Down
7 changes: 7 additions & 0 deletions generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,13 @@ service {
retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
}

service {
service_proto_path: "google/cloud/kms/v1/ekm_service.proto"
product_path: "google/cloud/kms"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

# Language
service {
service_proto_path: "google/cloud/language/v1/language_service.proto"
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/kms/doc/main.dox
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ which should give you a taste of the KMS C++ client library API.

## Environment Variables

- `GOOGLE_CLOUD_CPP_EKM_SERVICE_ENDPOINT=...` changes the default endpoint
(cloudkms.googleapis.com) used by `EkmServiceConnection`.

- `GOOGLE_CLOUD_CPP_KEY_MANAGEMENT_SERVICE_ENDPOINT=...` changes the default endpoint
(cloudkms.googleapis.com) used by `KeyManagementServiceConnection`.

Expand Down
109 changes: 109 additions & 0 deletions google/cloud/kms/ekm_client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/cloud/kms/v1/ekm_service.proto

#include "google/cloud/kms/ekm_client.h"
#include "google/cloud/kms/internal/ekm_option_defaults.h"
#include <memory>

namespace google {
namespace cloud {
namespace kms {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

EkmServiceClient::EkmServiceClient(
std::shared_ptr<EkmServiceConnection> connection, Options opts)
: connection_(std::move(connection)),
options_(internal::MergeOptions(
std::move(opts),
kms_internal::EkmServiceDefaultOptions(connection_->options()))) {}
EkmServiceClient::~EkmServiceClient() = default;

StreamRange<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::ListEkmConnections(std::string const& parent, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::cloud::kms::v1::ListEkmConnectionsRequest request;
request.set_parent(parent);
return connection_->ListEkmConnections(request);
}

StreamRange<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::ListEkmConnections(
google::cloud::kms::v1::ListEkmConnectionsRequest request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->ListEkmConnections(std::move(request));
}

StatusOr<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::GetEkmConnection(std::string const& name, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::cloud::kms::v1::GetEkmConnectionRequest request;
request.set_name(name);
return connection_->GetEkmConnection(request);
}

StatusOr<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::GetEkmConnection(
google::cloud::kms::v1::GetEkmConnectionRequest const& request,
Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->GetEkmConnection(request);
}

StatusOr<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::CreateEkmConnection(
std::string const& parent, std::string const& ekm_connection_id,
google::cloud::kms::v1::EkmConnection const& ekm_connection, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::cloud::kms::v1::CreateEkmConnectionRequest request;
request.set_parent(parent);
request.set_ekm_connection_id(ekm_connection_id);
*request.mutable_ekm_connection() = ekm_connection;
return connection_->CreateEkmConnection(request);
}

StatusOr<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::CreateEkmConnection(
google::cloud::kms::v1::CreateEkmConnectionRequest const& request,
Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateEkmConnection(request);
}

StatusOr<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::UpdateEkmConnection(
google::cloud::kms::v1::EkmConnection const& ekm_connection,
google::protobuf::FieldMask const& update_mask, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::cloud::kms::v1::UpdateEkmConnectionRequest request;
*request.mutable_ekm_connection() = ekm_connection;
*request.mutable_update_mask() = update_mask;
return connection_->UpdateEkmConnection(request);
}

StatusOr<google::cloud::kms::v1::EkmConnection>
EkmServiceClient::UpdateEkmConnection(
google::cloud::kms::v1::UpdateEkmConnectionRequest const& request,
Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->UpdateEkmConnection(request);
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace kms
} // namespace cloud
} // namespace google
Loading