-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kms): add KMS Inventory API (#10945)
- Loading branch information
Showing
66 changed files
with
4,038 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@com_google_googleapis//google/cloud/kms/inventory/v1:key_dashboard_service.proto | ||
@com_google_googleapis//google/cloud/kms/inventory/v1:key_tracking_service.proto | ||
@com_google_googleapis//google/cloud/kms/v1:ekm_service.proto | ||
@com_google_googleapis//google/cloud/kms/v1:resources.proto | ||
@com_google_googleapis//google/cloud/kms/v1:service.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
google/cloud/kms/inventory/v1/internal/key_dashboard_auth_decorator.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2023 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/inventory/v1/key_dashboard_service.proto | ||
|
||
#include "google/cloud/kms/inventory/v1/internal/key_dashboard_auth_decorator.h" | ||
#include <google/cloud/kms/inventory/v1/key_dashboard_service.grpc.pb.h> | ||
#include <memory> | ||
|
||
namespace google { | ||
namespace cloud { | ||
namespace kms_inventory_v1_internal { | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
|
||
KeyDashboardServiceAuth::KeyDashboardServiceAuth( | ||
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth, | ||
std::shared_ptr<KeyDashboardServiceStub> child) | ||
: auth_(std::move(auth)), child_(std::move(child)) {} | ||
|
||
StatusOr<google::cloud::kms::inventory::v1::ListCryptoKeysResponse> | ||
KeyDashboardServiceAuth::ListCryptoKeys( | ||
grpc::ClientContext& context, | ||
google::cloud::kms::inventory::v1::ListCryptoKeysRequest const& request) { | ||
auto status = auth_->ConfigureContext(context); | ||
if (!status.ok()) return status; | ||
return child_->ListCryptoKeys(context, request); | ||
} | ||
|
||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace kms_inventory_v1_internal | ||
} // namespace cloud | ||
} // namespace google |
56 changes: 56 additions & 0 deletions
56
google/cloud/kms/inventory/v1/internal/key_dashboard_auth_decorator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2023 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/inventory/v1/key_dashboard_service.proto | ||
|
||
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_KMS_INVENTORY_V1_INTERNAL_KEY_DASHBOARD_AUTH_DECORATOR_H | ||
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_KMS_INVENTORY_V1_INTERNAL_KEY_DASHBOARD_AUTH_DECORATOR_H | ||
|
||
#include "google/cloud/kms/inventory/v1/internal/key_dashboard_stub.h" | ||
#include "google/cloud/internal/unified_grpc_credentials.h" | ||
#include "google/cloud/version.h" | ||
#include <memory> | ||
#include <set> | ||
#include <string> | ||
|
||
namespace google { | ||
namespace cloud { | ||
namespace kms_inventory_v1_internal { | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
|
||
class KeyDashboardServiceAuth : public KeyDashboardServiceStub { | ||
public: | ||
~KeyDashboardServiceAuth() override = default; | ||
KeyDashboardServiceAuth( | ||
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth, | ||
std::shared_ptr<KeyDashboardServiceStub> child); | ||
|
||
StatusOr<google::cloud::kms::inventory::v1::ListCryptoKeysResponse> | ||
ListCryptoKeys(grpc::ClientContext& context, | ||
google::cloud::kms::inventory::v1::ListCryptoKeysRequest const& | ||
request) override; | ||
|
||
private: | ||
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth_; | ||
std::shared_ptr<KeyDashboardServiceStub> child_; | ||
}; | ||
|
||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace kms_inventory_v1_internal | ||
} // namespace cloud | ||
} // namespace google | ||
|
||
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_KMS_INVENTORY_V1_INTERNAL_KEY_DASHBOARD_AUTH_DECORATOR_H |
78 changes: 78 additions & 0 deletions
78
google/cloud/kms/inventory/v1/internal/key_dashboard_connection_impl.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2023 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/inventory/v1/key_dashboard_service.proto | ||
|
||
#include "google/cloud/kms/inventory/v1/internal/key_dashboard_connection_impl.h" | ||
#include "google/cloud/kms/inventory/v1/internal/key_dashboard_option_defaults.h" | ||
#include "google/cloud/background_threads.h" | ||
#include "google/cloud/common_options.h" | ||
#include "google/cloud/grpc_options.h" | ||
#include "google/cloud/internal/pagination_range.h" | ||
#include "google/cloud/internal/retry_loop.h" | ||
#include <memory> | ||
|
||
namespace google { | ||
namespace cloud { | ||
namespace kms_inventory_v1_internal { | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
|
||
KeyDashboardServiceConnectionImpl::KeyDashboardServiceConnectionImpl( | ||
std::unique_ptr<google::cloud::BackgroundThreads> background, | ||
std::shared_ptr<kms_inventory_v1_internal::KeyDashboardServiceStub> stub, | ||
Options options) | ||
: background_(std::move(background)), | ||
stub_(std::move(stub)), | ||
options_(internal::MergeOptions( | ||
std::move(options), KeyDashboardServiceConnection::options())) {} | ||
|
||
StreamRange<google::cloud::kms::v1::CryptoKey> | ||
KeyDashboardServiceConnectionImpl::ListCryptoKeys( | ||
google::cloud::kms::inventory::v1::ListCryptoKeysRequest request) { | ||
request.clear_page_token(); | ||
auto& stub = stub_; | ||
auto retry = | ||
std::shared_ptr<kms_inventory_v1::KeyDashboardServiceRetryPolicy const>( | ||
retry_policy()); | ||
auto backoff = std::shared_ptr<BackoffPolicy const>(backoff_policy()); | ||
auto idempotency = idempotency_policy()->ListCryptoKeys(request); | ||
char const* function_name = __func__; | ||
return google::cloud::internal::MakePaginationRange< | ||
StreamRange<google::cloud::kms::v1::CryptoKey>>( | ||
std::move(request), | ||
[stub, retry, backoff, idempotency, function_name]( | ||
google::cloud::kms::inventory::v1::ListCryptoKeysRequest const& r) { | ||
return google::cloud::internal::RetryLoop( | ||
retry->clone(), backoff->clone(), idempotency, | ||
[stub]( | ||
grpc::ClientContext& context, | ||
google::cloud::kms::inventory::v1::ListCryptoKeysRequest const& | ||
request) { return stub->ListCryptoKeys(context, request); }, | ||
r, function_name); | ||
}, | ||
[](google::cloud::kms::inventory::v1::ListCryptoKeysResponse r) { | ||
std::vector<google::cloud::kms::v1::CryptoKey> result( | ||
r.crypto_keys().size()); | ||
auto& messages = *r.mutable_crypto_keys(); | ||
std::move(messages.begin(), messages.end(), result.begin()); | ||
return result; | ||
}); | ||
} | ||
|
||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace kms_inventory_v1_internal | ||
} // namespace cloud | ||
} // namespace google |
Oops, something went wrong.