Class: Google::Cloud::Kms::V1::KeyManagementServiceClient
- Inherits:
-
Object
- Object
- Google::Cloud::Kms::V1::KeyManagementServiceClient
- Defined in:
- lib/google/cloud/kms/v1/key_management_service_client.rb
Overview
Google Cloud Key Management Service
Manages cryptographic keys and operations using those keys. Implements a REST model with the following objects:
Constant Summary collapse
- SERVICE_ADDRESS =
The default address of the service.
"cloudkms.googleapis.com".freeze
- DEFAULT_SERVICE_PORT =
The default port of the service.
443
- GRPC_INTERCEPTORS =
The default set of gRPC interceptors.
[]
- DEFAULT_TIMEOUT =
30
- ALL_SCOPES =
The scopes needed to make gRPC calls to all of the methods defined in this service.
[ "https://www.googleapis.com/auth/cloud-platform" ].freeze
Instance Attribute Summary collapse
- #iam_policy_stub ⇒ Google::Iam::V1::IAMPolicy::Stub readonly
- #key_management_service_stub ⇒ Google::Cloud::Kms::V1::KeyManagementService::Stub readonly
Class Method Summary collapse
-
.crypto_key_path(project, location, key_ring, crypto_key) ⇒ String
Returns a fully-qualified crypto_key resource name string.
-
.crypto_key_path_path(project, location, key_ring, crypto_key_path) ⇒ String
Returns a fully-qualified crypto_key_path resource name string.
-
.crypto_key_version_path(project, location, key_ring, crypto_key, crypto_key_version) ⇒ String
Returns a fully-qualified crypto_key_version resource name string.
-
.key_ring_path(project, location, key_ring) ⇒ String
Returns a fully-qualified key_ring resource name string.
-
.location_path(project, location) ⇒ String
Returns a fully-qualified location resource name string.
Instance Method Summary collapse
- #create_crypto_key(parent, crypto_key_id, crypto_key, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
-
#create_crypto_key_version(parent, crypto_key_version, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Create a new CryptoKeyVersion in a CryptoKey.
-
#create_key_ring(parent, key_ring_id, key_ring, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::KeyRing
Create a new KeyRing in a given Project and Location.
-
#decrypt(name, ciphertext, additional_authenticated_data: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::DecryptResponse
Decrypts data that was protected by Encrypt.
-
#destroy_crypto_key_version(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Schedule a CryptoKeyVersion for destruction.
-
#encrypt(name, plaintext, additional_authenticated_data: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::EncryptResponse
Encrypts data, so that it can only be recovered by a call to Decrypt.
-
#get_crypto_key(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
-
#get_crypto_key_version(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Returns metadata for a given CryptoKeyVersion.
-
#get_iam_policy(resource, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::Policy
Gets the access control policy for a resource.
-
#get_key_ring(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::KeyRing
Returns metadata for a given KeyRing.
-
#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ KeyManagementServiceClient
constructor
A new instance of KeyManagementServiceClient.
-
#list_crypto_key_versions(parent, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>
Lists CryptoKeyVersions.
-
#list_crypto_keys(parent, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>
Lists CryptoKeys.
-
#list_key_rings(parent, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>
Lists KeyRings.
-
#restore_crypto_key_version(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Restore a CryptoKeyVersion in the DESTROY_SCHEDULED, state.
-
#set_iam_policy(resource, policy, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::Policy
Sets the access control policy on the specified resource.
-
#test_iam_permissions(resource, permissions, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::TestIamPermissionsResponse
Returns permissions that a caller has on the specified resource.
-
#update_crypto_key(crypto_key, update_mask, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Update a CryptoKey.
-
#update_crypto_key_primary_version(name, crypto_key_version_id, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Update the version of a CryptoKey that will be used in Encrypt.
-
#update_crypto_key_version(crypto_key_version, update_mask, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Update a CryptoKeyVersion's metadata.
Constructor Details
#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ KeyManagementServiceClient
Returns a new instance of KeyManagementServiceClient
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 216 def initialize \ credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "" # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "google/gax/grpc" require "google/cloud/kms/v1/service_services_pb" require "google/iam/v1/iam_policy_services_pb" credentials ||= Google::Cloud::Kms::V1::Credentials.default if credentials.is_a?(String) || credentials.is_a?(Hash) updater_proc = Google::Cloud::Kms::V1::Credentials.new(credentials).updater_proc end if credentials.is_a?(GRPC::Core::Channel) channel = credentials end if credentials.is_a?(GRPC::Core::ChannelCredentials) chan_creds = credentials end if credentials.is_a?(Proc) updater_proc = credentials end if credentials.is_a?(Google::Auth::Credentials) updater_proc = credentials.updater_proc end package_version = Gem.loaded_specs['google-cloud-kms'].version.version google_api_client = "gl-ruby/#{RUBY_VERSION}" google_api_client << " #{lib_name}/#{lib_version}" if lib_name google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" google_api_client << " grpc/#{GRPC::VERSION}" google_api_client.freeze headers = { :"x-goog-api-client" => google_api_client } headers.merge!() unless .nil? client_config_file = Pathname.new(__dir__).join( "key_management_service_client_config.json" ) defaults = client_config_file.open do |f| Google::Gax.construct_settings( "google.cloud.kms.v1.KeyManagementService", JSON.parse(f.read), client_config, Google::Gax::Grpc::STATUS_CODE_NAMES, timeout, page_descriptors: PAGE_DESCRIPTORS, errors: Google::Gax::Grpc::API_ERRORS, metadata: headers ) end # Allow overriding the service path/port in subclasses. service_path = self.class::SERVICE_ADDRESS port = self.class::DEFAULT_SERVICE_PORT interceptors = self.class::GRPC_INTERCEPTORS @key_management_service_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Cloud::Kms::V1::KeyManagementService::Stub.method(:new) ) @iam_policy_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Iam::V1::IAMPolicy::Stub.method(:new) ) @list_key_rings = Google::Gax.create_api_call( @key_management_service_stub.method(:list_key_rings), defaults["list_key_rings"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @list_crypto_keys = Google::Gax.create_api_call( @key_management_service_stub.method(:list_crypto_keys), defaults["list_crypto_keys"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @list_crypto_key_versions = Google::Gax.create_api_call( @key_management_service_stub.method(:list_crypto_key_versions), defaults["list_crypto_key_versions"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @get_key_ring = Google::Gax.create_api_call( @key_management_service_stub.method(:get_key_ring), defaults["get_key_ring"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:get_crypto_key), defaults["get_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:get_crypto_key_version), defaults["get_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @create_key_ring = Google::Gax.create_api_call( @key_management_service_stub.method(:create_key_ring), defaults["create_key_ring"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @create_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:create_crypto_key), defaults["create_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @create_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:create_crypto_key_version), defaults["create_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @update_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key), defaults["update_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'crypto_key.name' => request.crypto_key.name} end ) @update_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key_version), defaults["update_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'crypto_key_version.name' => request.crypto_key_version.name} end ) @encrypt = Google::Gax.create_api_call( @key_management_service_stub.method(:encrypt), defaults["encrypt"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @decrypt = Google::Gax.create_api_call( @key_management_service_stub.method(:decrypt), defaults["decrypt"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @update_crypto_key_primary_version = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key_primary_version), defaults["update_crypto_key_primary_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @destroy_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:destroy_crypto_key_version), defaults["destroy_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @restore_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:restore_crypto_key_version), defaults["restore_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @set_iam_policy = Google::Gax.create_api_call( @iam_policy_stub.method(:set_iam_policy), defaults["set_iam_policy"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) @get_iam_policy = Google::Gax.create_api_call( @iam_policy_stub.method(:get_iam_policy), defaults["get_iam_policy"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) @test_iam_permissions = Google::Gax.create_api_call( @iam_policy_stub.method(:test_iam_permissions), defaults["test_iam_permissions"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) end |
Instance Attribute Details
#iam_policy_stub ⇒ Google::Iam::V1::IAMPolicy::Stub (readonly)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 48 class KeyManagementServiceClient attr_reader :key_management_service_stub, :iam_policy_stub # The default address of the service. SERVICE_ADDRESS = "cloudkms.googleapis.com".freeze # The default port of the service. DEFAULT_SERVICE_PORT = 443 # The default set of gRPC interceptors. GRPC_INTERCEPTORS = [] DEFAULT_TIMEOUT = 30 PAGE_DESCRIPTORS = { "list_key_rings" => Google::Gax::PageDescriptor.new( "page_token", "next_page_token", "key_rings"), "list_crypto_keys" => Google::Gax::PageDescriptor.new( "page_token", "next_page_token", "crypto_keys"), "list_crypto_key_versions" => Google::Gax::PageDescriptor.new( "page_token", "next_page_token", "crypto_key_versions") }.freeze private_constant :PAGE_DESCRIPTORS # The scopes needed to make gRPC calls to all of the methods defined in # this service. ALL_SCOPES = [ "https://www.googleapis.com/auth/cloud-platform" ].freeze KEY_RING_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}" ) private_constant :KEY_RING_PATH_TEMPLATE CRYPTO_KEY_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}" ) private_constant :CRYPTO_KEY_PATH_PATH_TEMPLATE LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}" ) private_constant :LOCATION_PATH_TEMPLATE CRYPTO_KEY_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" ) private_constant :CRYPTO_KEY_PATH_TEMPLATE CRYPTO_KEY_VERSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}" ) private_constant :CRYPTO_KEY_VERSION_PATH_TEMPLATE # Returns a fully-qualified key_ring resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @return [String] def self.key_ring_path project, location, key_ring KEY_RING_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring ) end # Returns a fully-qualified crypto_key_path resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @param crypto_key_path [String] # @return [String] def self.crypto_key_path_path project, location, key_ring, crypto_key_path CRYPTO_KEY_PATH_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key_path" => crypto_key_path ) end # Returns a fully-qualified location resource name string. # @param project [String] # @param location [String] # @return [String] def self.location_path project, location LOCATION_PATH_TEMPLATE.render( :"project" => project, :"location" => location ) end # Returns a fully-qualified crypto_key resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @param crypto_key [String] # @return [String] def self.crypto_key_path project, location, key_ring, crypto_key CRYPTO_KEY_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key" => crypto_key ) end # Returns a fully-qualified crypto_key_version resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @param crypto_key [String] # @param crypto_key_version [String] # @return [String] def self.crypto_key_version_path project, location, key_ring, crypto_key, crypto_key_version CRYPTO_KEY_VERSION_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key" => crypto_key, :"crypto_key_version" => crypto_key_version ) end # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] # Provides the means for authenticating requests made by the client. This parameter can # be many types. # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for # authenticating requests made by this client. # A `String` will be treated as the path to the keyfile to be used for the construction of # credentials for this client. # A `Hash` will be treated as the contents of a keyfile to be used for the construction of # credentials for this client. # A `GRPC::Core::Channel` will be used to make calls through. # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials # should already be composed with a `GRPC::Core::CallCredentials` object. # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the # metadata for requests, generally, to give OAuth credentials. # @param scopes [Array<String>] # The OAuth scopes for this service. This parameter is ignored if # an updater_proc is supplied. # @param client_config [Hash] # A Hash for call options for each method. See # Google::Gax#construct_settings for the structure of # this data. Falls back to the default config if not specified # or the specified config is missing data points. # @param timeout [Numeric] # The default timeout, in seconds, for calls made through this client. # @param metadata [Hash] # Default metadata to be sent with each request. This can be overridden on a per call basis. # @param exception_transformer [Proc] # An optional proc that intercepts any exceptions raised during an API call to inject # custom error handling. def initialize \ credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "" # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "google/gax/grpc" require "google/cloud/kms/v1/service_services_pb" require "google/iam/v1/iam_policy_services_pb" credentials ||= Google::Cloud::Kms::V1::Credentials.default if credentials.is_a?(String) || credentials.is_a?(Hash) updater_proc = Google::Cloud::Kms::V1::Credentials.new(credentials).updater_proc end if credentials.is_a?(GRPC::Core::Channel) channel = credentials end if credentials.is_a?(GRPC::Core::ChannelCredentials) chan_creds = credentials end if credentials.is_a?(Proc) updater_proc = credentials end if credentials.is_a?(Google::Auth::Credentials) updater_proc = credentials.updater_proc end package_version = Gem.loaded_specs['google-cloud-kms'].version.version google_api_client = "gl-ruby/#{RUBY_VERSION}" google_api_client << " #{lib_name}/#{lib_version}" if lib_name google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" google_api_client << " grpc/#{GRPC::VERSION}" google_api_client.freeze headers = { :"x-goog-api-client" => google_api_client } headers.merge!() unless .nil? client_config_file = Pathname.new(__dir__).join( "key_management_service_client_config.json" ) defaults = client_config_file.open do |f| Google::Gax.construct_settings( "google.cloud.kms.v1.KeyManagementService", JSON.parse(f.read), client_config, Google::Gax::Grpc::STATUS_CODE_NAMES, timeout, page_descriptors: PAGE_DESCRIPTORS, errors: Google::Gax::Grpc::API_ERRORS, metadata: headers ) end # Allow overriding the service path/port in subclasses. service_path = self.class::SERVICE_ADDRESS port = self.class::DEFAULT_SERVICE_PORT interceptors = self.class::GRPC_INTERCEPTORS @key_management_service_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Cloud::Kms::V1::KeyManagementService::Stub.method(:new) ) @iam_policy_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Iam::V1::IAMPolicy::Stub.method(:new) ) @list_key_rings = Google::Gax.create_api_call( @key_management_service_stub.method(:list_key_rings), defaults["list_key_rings"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @list_crypto_keys = Google::Gax.create_api_call( @key_management_service_stub.method(:list_crypto_keys), defaults["list_crypto_keys"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @list_crypto_key_versions = Google::Gax.create_api_call( @key_management_service_stub.method(:list_crypto_key_versions), defaults["list_crypto_key_versions"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @get_key_ring = Google::Gax.create_api_call( @key_management_service_stub.method(:get_key_ring), defaults["get_key_ring"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:get_crypto_key), defaults["get_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:get_crypto_key_version), defaults["get_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @create_key_ring = Google::Gax.create_api_call( @key_management_service_stub.method(:create_key_ring), defaults["create_key_ring"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @create_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:create_crypto_key), defaults["create_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @create_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:create_crypto_key_version), defaults["create_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @update_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key), defaults["update_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'crypto_key.name' => request.crypto_key.name} end ) @update_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key_version), defaults["update_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'crypto_key_version.name' => request.crypto_key_version.name} end ) @encrypt = Google::Gax.create_api_call( @key_management_service_stub.method(:encrypt), defaults["encrypt"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @decrypt = Google::Gax.create_api_call( @key_management_service_stub.method(:decrypt), defaults["decrypt"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @update_crypto_key_primary_version = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key_primary_version), defaults["update_crypto_key_primary_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @destroy_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:destroy_crypto_key_version), defaults["destroy_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @restore_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:restore_crypto_key_version), defaults["restore_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @set_iam_policy = Google::Gax.create_api_call( @iam_policy_stub.method(:set_iam_policy), defaults["set_iam_policy"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) @get_iam_policy = Google::Gax.create_api_call( @iam_policy_stub.method(:get_iam_policy), defaults["get_iam_policy"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) @test_iam_permissions = Google::Gax.create_api_call( @iam_policy_stub.method(:test_iam_permissions), defaults["test_iam_permissions"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) end # Service calls # Lists {Google::Cloud::Kms::V1::KeyRing KeyRings}. # # @param parent [String] # Required. The resource name of the location associated with the # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format +projects/*/locations/*+. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this # parameter does not affect the return value. If page streaming is # performed per-page, this determines the maximum number of # resources in a page. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>] # An enumerable of Google::Cloud::Kms::V1::KeyRing instances. # See Google::Gax::PagedEnumerable documentation for other # operations such as per-page iteration or access to the response # object. # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path("[PROJECT]", "[LOCATION]") # # # Iterate over all results. # key_management_service_client.list_key_rings(formatted_parent).each do |element| # # Process element. # end # # # Or iterate over results one page at a time. # key_management_service_client.list_key_rings(formatted_parent).each_page do |page| # # Process each page at a time. # page.each do |element| # # Process element. # end # end def list_key_rings \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListKeyRingsRequest) @list_key_rings.call(req, , &block) end # Lists {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}. # # @param parent [String] # Required. The resource name of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to list, in the format # +projects/*/locations/*/keyRings/*+. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this # parameter does not affect the return value. If page streaming is # performed per-page, this determines the maximum number of # resources in a page. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>] # An enumerable of Google::Cloud::Kms::V1::CryptoKey instances. # See Google::Gax::PagedEnumerable documentation for other # operations such as per-page iteration or access to the response # object. # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # # # Iterate over all results. # key_management_service_client.list_crypto_keys(formatted_parent).each do |element| # # Process element. # end # # # Or iterate over results one page at a time. # key_management_service_client.list_crypto_keys(formatted_parent).each_page do |page| # # Process each page at a time. # page.each do |element| # # Process element. # end # end def list_crypto_keys \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeysRequest) @list_crypto_keys.call(req, , &block) end # Lists {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}. # # @param parent [String] # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to list, in the format # +projects/*/locations/*/keyRings/*/cryptoKeys/*+. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this # parameter does not affect the return value. If page streaming is # performed per-page, this determines the maximum number of # resources in a page. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>] # An enumerable of Google::Cloud::Kms::V1::CryptoKeyVersion instances. # See Google::Gax::PagedEnumerable documentation for other # operations such as per-page iteration or access to the response # object. # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # Iterate over all results. # key_management_service_client.list_crypto_key_versions(formatted_parent).each do |element| # # Process element. # end # # # Or iterate over results one page at a time. # key_management_service_client.list_crypto_key_versions(formatted_parent).each_page do |page| # # Process each page at a time. # page.each do |element| # # Process element. # end # end def list_crypto_key_versions \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest) @list_crypto_key_versions.call(req, , &block) end # Returns metadata for a given {Google::Cloud::Kms::V1::KeyRing KeyRing}. # # @param name [String] # The {Google::Cloud::Kms::V1::KeyRing#name name} of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to get. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::KeyRing] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::KeyRing] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # response = key_management_service_client.get_key_ring(formatted_name) def get_key_ring \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetKeyRingRequest) @get_key_ring.call(req, , &block) end # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKey CryptoKey}, as well as its # {Google::Cloud::Kms::V1::CryptoKey#primary primary} {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}. # # @param name [String] # The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to get. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # response = key_management_service_client.get_crypto_key(formatted_name) def get_crypto_key \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyRequest) @get_crypto_key.call(req, , &block) end # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}. # # @param name [String] # The {Google::Cloud::Kms::V1::CryptoKeyVersion#name name} of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to get. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]") # response = key_management_service_client.get_crypto_key_version(formatted_name) def get_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest) @get_crypto_key_version.call(req, , &block) end # Create a new {Google::Cloud::Kms::V1::KeyRing KeyRing} in a given Project and Location. # # @param parent [String] # Required. The resource name of the location associated with the # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format +projects/*/locations/*+. # @param key_ring_id [String] # Required. It must be unique within a location and match the regular # expression +[a-zA-Z0-9_-]{1,63}+ # @param key_ring [Google::Cloud::Kms::V1::KeyRing | Hash] # A {Google::Cloud::Kms::V1::KeyRing KeyRing} with initial field values. # A hash of the same form as `Google::Cloud::Kms::V1::KeyRing` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::KeyRing] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::KeyRing] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path("[PROJECT]", "[LOCATION]") # # # TODO: Initialize +key_ring_id+: # key_ring_id = '' # # # TODO: Initialize +key_ring+: # key_ring = {} # response = key_management_service_client.create_key_ring(formatted_parent, key_ring_id, key_ring) def create_key_ring \ parent, key_ring_id, key_ring, options: nil, &block req = { parent: parent, key_ring_id: key_ring_id, key_ring: key_ring }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateKeyRingRequest) @create_key_ring.call(req, , &block) end # Create a new {Google::Cloud::Kms::V1::CryptoKey CryptoKey} within a {Google::Cloud::Kms::V1::KeyRing KeyRing}. # # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose} is required. # # @param parent [String] # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the KeyRing associated with the # {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}. # @param crypto_key_id [String] # Required. It must be unique within a KeyRing and match the regular # expression +[a-zA-Z0-9_-]{1,63}+ # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey | Hash] # A {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with initial field values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKey` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # crypto_key_id = "my-app-key" # purpose = :ENCRYPT_DECRYPT # seconds = 2147483647 # next_rotation_time = { seconds: seconds } # seconds_2 = 604800 # rotation_period = { seconds: seconds_2 } # crypto_key = { # purpose: purpose, # next_rotation_time: next_rotation_time, # rotation_period: rotation_period # } # response = key_management_service_client.create_crypto_key(formatted_parent, crypto_key_id, crypto_key) def create_crypto_key \ parent, crypto_key_id, crypto_key, options: nil, &block req = { parent: parent, crypto_key_id: crypto_key_id, crypto_key: crypto_key }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyRequest) @create_crypto_key.call(req, , &block) end # Create a new {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}. # # The server will assign the next sequential id. If unset, # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} will be set to # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED}. # # @param parent [String] # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} associated with # the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}. # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion | Hash] # A {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with initial field values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKeyVersion` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # TODO: Initialize +crypto_key_version+: # crypto_key_version = {} # response = key_management_service_client.create_crypto_key_version(formatted_parent, crypto_key_version) def create_crypto_key_version \ parent, crypto_key_version, options: nil, &block req = { parent: parent, crypto_key_version: crypto_key_version }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest) @create_crypto_key_version.call(req, , &block) end # Update a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}. # # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey | Hash] # {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with updated values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKey` # can also be provided. # @param update_mask [Google::Protobuf::FieldMask | Hash] # Required list of fields to be updated in this request. # A hash of the same form as `Google::Protobuf::FieldMask` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # # # TODO: Initialize +crypto_key+: # crypto_key = {} # # # TODO: Initialize +update_mask+: # update_mask = {} # response = key_management_service_client.update_crypto_key(crypto_key, update_mask) def update_crypto_key \ crypto_key, update_mask, options: nil, &block req = { crypto_key: crypto_key, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyRequest) @update_crypto_key.call(req, , &block) end # Update a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}'s metadata. # # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} may be changed between # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED} and # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED} using this # method. See {Google::Cloud::Kms::V1::KeyManagementService::DestroyCryptoKeyVersion DestroyCryptoKeyVersion} and {Google::Cloud::Kms::V1::KeyManagementService::RestoreCryptoKeyVersion RestoreCryptoKeyVersion} to # move between other states. # # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion | Hash] # {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with updated values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKeyVersion` # can also be provided. # @param update_mask [Google::Protobuf::FieldMask | Hash] # Required list of fields to be updated in this request. # A hash of the same form as `Google::Protobuf::FieldMask` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # # # TODO: Initialize +crypto_key_version+: # crypto_key_version = {} # # # TODO: Initialize +update_mask+: # update_mask = {} # response = key_management_service_client.update_crypto_key_version(crypto_key_version, update_mask) def update_crypto_key_version \ crypto_key_version, update_mask, options: nil, &block req = { crypto_key_version: crypto_key_version, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest) @update_crypto_key_version.call(req, , &block) end # Encrypts data, so that it can only be recovered by a call to {Google::Cloud::Kms::V1::KeyManagementService::Decrypt Decrypt}. # # @param name [String] # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} or {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} # to use for encryption. # # If a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} is specified, the server will use its # {Google::Cloud::Kms::V1::CryptoKey#primary primary version}. # @param plaintext [String] # Required. The data to encrypt. Must be no larger than 64KiB. # @param additional_authenticated_data [String] # Optional data that, if specified, must also be provided during decryption # through {Google::Cloud::Kms::V1::DecryptRequest#additional_authenticated_data DecryptRequest#additional_authenticated_data}. Must be no # larger than 64KiB. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::EncryptResponse] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::EncryptResponse] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY_PATH]") # # # TODO: Initialize +plaintext+: # plaintext = '' # response = key_management_service_client.encrypt(formatted_name, plaintext) def encrypt \ name, plaintext, additional_authenticated_data: nil, options: nil, &block req = { name: name, plaintext: plaintext, additional_authenticated_data: additional_authenticated_data }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::EncryptRequest) @encrypt.call(req, , &block) end # Decrypts data that was protected by {Google::Cloud::Kms::V1::KeyManagementService::Encrypt Encrypt}. # # @param name [String] # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to use for decryption. # The server will choose the appropriate version. # @param ciphertext [String] # Required. The encrypted data originally returned in # {Google::Cloud::Kms::V1::EncryptResponse#ciphertext EncryptResponse#ciphertext}. # @param additional_authenticated_data [String] # Optional data that must match the data originally supplied in # {Google::Cloud::Kms::V1::EncryptRequest#additional_authenticated_data EncryptRequest#additional_authenticated_data}. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::DecryptResponse] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::DecryptResponse] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # TODO: Initialize +ciphertext+: # ciphertext = '' # response = key_management_service_client.decrypt(formatted_name, ciphertext) def decrypt \ name, ciphertext, additional_authenticated_data: nil, options: nil, &block req = { name: name, ciphertext: ciphertext, additional_authenticated_data: additional_authenticated_data }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DecryptRequest) @decrypt.call(req, , &block) end # Update the version of a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} that will be used in {Google::Cloud::Kms::V1::KeyManagementService::Encrypt Encrypt} # # @param name [String] # The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to update. # @param crypto_key_version_id [String] # The id of the child {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use as primary. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # TODO: Initialize +crypto_key_version_id+: # crypto_key_version_id = '' # response = key_management_service_client.update_crypto_key_primary_version(formatted_name, crypto_key_version_id) def update_crypto_key_primary_version \ name, crypto_key_version_id, options: nil, &block req = { name: name, crypto_key_version_id: crypto_key_version_id }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest) @update_crypto_key_primary_version.call(req, , &block) end # Schedule a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} for destruction. # # Upon calling this method, {Google::Cloud::Kms::V1::CryptoKeyVersion#state CryptoKeyVersion#state} will be set to # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED} # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be set to a time 24 # hours in the future, at which point the {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} # will be changed to # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROYED DESTROYED}, and the key # material will be irrevocably destroyed. # # Before the {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} is reached, # {Google::Cloud::Kms::V1::KeyManagementService::RestoreCryptoKeyVersion RestoreCryptoKeyVersion} may be called to reverse the process. # # @param name [String] # The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to destroy. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]") # response = key_management_service_client.destroy_crypto_key_version(formatted_name) def destroy_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest) @destroy_crypto_key_version.call(req, , &block) end # Restore a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in the # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED}, # state. # # Upon restoration of the CryptoKeyVersion, {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} # will be set to {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED}, # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be cleared. # # @param name [String] # The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to restore. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]") # response = key_management_service_client.restore_crypto_key_version(formatted_name) def restore_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest) @restore_crypto_key_version.call(req, , &block) end # Sets the access control policy on the specified resource. Replaces any # existing policy. # # @param resource [String] # REQUIRED: The resource for which the policy is being specified. # +resource+ is usually specified as a path. For example, a Project # resource is specified as +projects/{project}+. # @param policy [Google::Iam::V1::Policy | Hash] # REQUIRED: The complete policy to be applied to the +resource+. The size of # the policy is limited to a few 10s of KB. An empty policy is a # valid policy but certain Cloud Platform services (such as Projects) # might reject them. # A hash of the same form as `Google::Iam::V1::Policy` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Iam::V1::Policy] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Iam::V1::Policy] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # # # TODO: Initialize +policy+: # policy = {} # response = key_management_service_client.set_iam_policy(formatted_resource, policy) def set_iam_policy \ resource, policy, options: nil, &block req = { resource: resource, policy: policy }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest) @set_iam_policy.call(req, , &block) end # Gets the access control policy for a resource. # Returns an empty policy if the resource exists and does not have a policy # set. # # @param resource [String] # REQUIRED: The resource for which the policy is being requested. # +resource+ is usually specified as a path. For example, a Project # resource is specified as +projects/{project}+. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Iam::V1::Policy] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Iam::V1::Policy] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # response = key_management_service_client.get_iam_policy(formatted_resource) def get_iam_policy \ resource, options: nil, &block req = { resource: resource }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest) @get_iam_policy.call(req, , &block) end # Returns permissions that a caller has on the specified resource. # If the resource does not exist, this will return an empty set of # permissions, not a NOT_FOUND error. # # @param resource [String] # REQUIRED: The resource for which the policy detail is being requested. # +resource+ is usually specified as a path. For example, a Project # resource is specified as +projects/{project}+. # @param permissions [Array<String>] # The set of permissions to check for the +resource+. Permissions with # wildcards (such as '*' or 'storage.*') are not allowed. For more # information see # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Iam::V1::TestIamPermissionsResponse] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # # # TODO: Initialize +permissions+: # permissions = [] # response = key_management_service_client.test_iam_permissions(formatted_resource, permissions) def \ resource, , options: nil, &block req = { resource: resource, permissions: }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest) @test_iam_permissions.call(req, , &block) end end |
#key_management_service_stub ⇒ Google::Cloud::Kms::V1::KeyManagementService::Stub (readonly)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 48 class KeyManagementServiceClient attr_reader :key_management_service_stub, :iam_policy_stub # The default address of the service. SERVICE_ADDRESS = "cloudkms.googleapis.com".freeze # The default port of the service. DEFAULT_SERVICE_PORT = 443 # The default set of gRPC interceptors. GRPC_INTERCEPTORS = [] DEFAULT_TIMEOUT = 30 PAGE_DESCRIPTORS = { "list_key_rings" => Google::Gax::PageDescriptor.new( "page_token", "next_page_token", "key_rings"), "list_crypto_keys" => Google::Gax::PageDescriptor.new( "page_token", "next_page_token", "crypto_keys"), "list_crypto_key_versions" => Google::Gax::PageDescriptor.new( "page_token", "next_page_token", "crypto_key_versions") }.freeze private_constant :PAGE_DESCRIPTORS # The scopes needed to make gRPC calls to all of the methods defined in # this service. ALL_SCOPES = [ "https://www.googleapis.com/auth/cloud-platform" ].freeze KEY_RING_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}" ) private_constant :KEY_RING_PATH_TEMPLATE CRYPTO_KEY_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}" ) private_constant :CRYPTO_KEY_PATH_PATH_TEMPLATE LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}" ) private_constant :LOCATION_PATH_TEMPLATE CRYPTO_KEY_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}" ) private_constant :CRYPTO_KEY_PATH_TEMPLATE CRYPTO_KEY_VERSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}" ) private_constant :CRYPTO_KEY_VERSION_PATH_TEMPLATE # Returns a fully-qualified key_ring resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @return [String] def self.key_ring_path project, location, key_ring KEY_RING_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring ) end # Returns a fully-qualified crypto_key_path resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @param crypto_key_path [String] # @return [String] def self.crypto_key_path_path project, location, key_ring, crypto_key_path CRYPTO_KEY_PATH_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key_path" => crypto_key_path ) end # Returns a fully-qualified location resource name string. # @param project [String] # @param location [String] # @return [String] def self.location_path project, location LOCATION_PATH_TEMPLATE.render( :"project" => project, :"location" => location ) end # Returns a fully-qualified crypto_key resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @param crypto_key [String] # @return [String] def self.crypto_key_path project, location, key_ring, crypto_key CRYPTO_KEY_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key" => crypto_key ) end # Returns a fully-qualified crypto_key_version resource name string. # @param project [String] # @param location [String] # @param key_ring [String] # @param crypto_key [String] # @param crypto_key_version [String] # @return [String] def self.crypto_key_version_path project, location, key_ring, crypto_key, crypto_key_version CRYPTO_KEY_VERSION_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key" => crypto_key, :"crypto_key_version" => crypto_key_version ) end # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] # Provides the means for authenticating requests made by the client. This parameter can # be many types. # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for # authenticating requests made by this client. # A `String` will be treated as the path to the keyfile to be used for the construction of # credentials for this client. # A `Hash` will be treated as the contents of a keyfile to be used for the construction of # credentials for this client. # A `GRPC::Core::Channel` will be used to make calls through. # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials # should already be composed with a `GRPC::Core::CallCredentials` object. # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the # metadata for requests, generally, to give OAuth credentials. # @param scopes [Array<String>] # The OAuth scopes for this service. This parameter is ignored if # an updater_proc is supplied. # @param client_config [Hash] # A Hash for call options for each method. See # Google::Gax#construct_settings for the structure of # this data. Falls back to the default config if not specified # or the specified config is missing data points. # @param timeout [Numeric] # The default timeout, in seconds, for calls made through this client. # @param metadata [Hash] # Default metadata to be sent with each request. This can be overridden on a per call basis. # @param exception_transformer [Proc] # An optional proc that intercepts any exceptions raised during an API call to inject # custom error handling. def initialize \ credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "" # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "google/gax/grpc" require "google/cloud/kms/v1/service_services_pb" require "google/iam/v1/iam_policy_services_pb" credentials ||= Google::Cloud::Kms::V1::Credentials.default if credentials.is_a?(String) || credentials.is_a?(Hash) updater_proc = Google::Cloud::Kms::V1::Credentials.new(credentials).updater_proc end if credentials.is_a?(GRPC::Core::Channel) channel = credentials end if credentials.is_a?(GRPC::Core::ChannelCredentials) chan_creds = credentials end if credentials.is_a?(Proc) updater_proc = credentials end if credentials.is_a?(Google::Auth::Credentials) updater_proc = credentials.updater_proc end package_version = Gem.loaded_specs['google-cloud-kms'].version.version google_api_client = "gl-ruby/#{RUBY_VERSION}" google_api_client << " #{lib_name}/#{lib_version}" if lib_name google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" google_api_client << " grpc/#{GRPC::VERSION}" google_api_client.freeze headers = { :"x-goog-api-client" => google_api_client } headers.merge!() unless .nil? client_config_file = Pathname.new(__dir__).join( "key_management_service_client_config.json" ) defaults = client_config_file.open do |f| Google::Gax.construct_settings( "google.cloud.kms.v1.KeyManagementService", JSON.parse(f.read), client_config, Google::Gax::Grpc::STATUS_CODE_NAMES, timeout, page_descriptors: PAGE_DESCRIPTORS, errors: Google::Gax::Grpc::API_ERRORS, metadata: headers ) end # Allow overriding the service path/port in subclasses. service_path = self.class::SERVICE_ADDRESS port = self.class::DEFAULT_SERVICE_PORT interceptors = self.class::GRPC_INTERCEPTORS @key_management_service_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Cloud::Kms::V1::KeyManagementService::Stub.method(:new) ) @iam_policy_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Google::Iam::V1::IAMPolicy::Stub.method(:new) ) @list_key_rings = Google::Gax.create_api_call( @key_management_service_stub.method(:list_key_rings), defaults["list_key_rings"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @list_crypto_keys = Google::Gax.create_api_call( @key_management_service_stub.method(:list_crypto_keys), defaults["list_crypto_keys"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @list_crypto_key_versions = Google::Gax.create_api_call( @key_management_service_stub.method(:list_crypto_key_versions), defaults["list_crypto_key_versions"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @get_key_ring = Google::Gax.create_api_call( @key_management_service_stub.method(:get_key_ring), defaults["get_key_ring"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:get_crypto_key), defaults["get_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:get_crypto_key_version), defaults["get_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @create_key_ring = Google::Gax.create_api_call( @key_management_service_stub.method(:create_key_ring), defaults["create_key_ring"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @create_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:create_crypto_key), defaults["create_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @create_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:create_crypto_key_version), defaults["create_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @update_crypto_key = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key), defaults["update_crypto_key"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'crypto_key.name' => request.crypto_key.name} end ) @update_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key_version), defaults["update_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'crypto_key_version.name' => request.crypto_key_version.name} end ) @encrypt = Google::Gax.create_api_call( @key_management_service_stub.method(:encrypt), defaults["encrypt"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @decrypt = Google::Gax.create_api_call( @key_management_service_stub.method(:decrypt), defaults["decrypt"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @update_crypto_key_primary_version = Google::Gax.create_api_call( @key_management_service_stub.method(:update_crypto_key_primary_version), defaults["update_crypto_key_primary_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @destroy_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:destroy_crypto_key_version), defaults["destroy_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @restore_crypto_key_version = Google::Gax.create_api_call( @key_management_service_stub.method(:restore_crypto_key_version), defaults["restore_crypto_key_version"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @set_iam_policy = Google::Gax.create_api_call( @iam_policy_stub.method(:set_iam_policy), defaults["set_iam_policy"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) @get_iam_policy = Google::Gax.create_api_call( @iam_policy_stub.method(:get_iam_policy), defaults["get_iam_policy"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) @test_iam_permissions = Google::Gax.create_api_call( @iam_policy_stub.method(:test_iam_permissions), defaults["test_iam_permissions"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'resource' => request.resource} end ) end # Service calls # Lists {Google::Cloud::Kms::V1::KeyRing KeyRings}. # # @param parent [String] # Required. The resource name of the location associated with the # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format +projects/*/locations/*+. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this # parameter does not affect the return value. If page streaming is # performed per-page, this determines the maximum number of # resources in a page. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>] # An enumerable of Google::Cloud::Kms::V1::KeyRing instances. # See Google::Gax::PagedEnumerable documentation for other # operations such as per-page iteration or access to the response # object. # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path("[PROJECT]", "[LOCATION]") # # # Iterate over all results. # key_management_service_client.list_key_rings(formatted_parent).each do |element| # # Process element. # end # # # Or iterate over results one page at a time. # key_management_service_client.list_key_rings(formatted_parent).each_page do |page| # # Process each page at a time. # page.each do |element| # # Process element. # end # end def list_key_rings \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListKeyRingsRequest) @list_key_rings.call(req, , &block) end # Lists {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}. # # @param parent [String] # Required. The resource name of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to list, in the format # +projects/*/locations/*/keyRings/*+. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this # parameter does not affect the return value. If page streaming is # performed per-page, this determines the maximum number of # resources in a page. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>] # An enumerable of Google::Cloud::Kms::V1::CryptoKey instances. # See Google::Gax::PagedEnumerable documentation for other # operations such as per-page iteration or access to the response # object. # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # # # Iterate over all results. # key_management_service_client.list_crypto_keys(formatted_parent).each do |element| # # Process element. # end # # # Or iterate over results one page at a time. # key_management_service_client.list_crypto_keys(formatted_parent).each_page do |page| # # Process each page at a time. # page.each do |element| # # Process element. # end # end def list_crypto_keys \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeysRequest) @list_crypto_keys.call(req, , &block) end # Lists {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}. # # @param parent [String] # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to list, in the format # +projects/*/locations/*/keyRings/*/cryptoKeys/*+. # @param page_size [Integer] # The maximum number of resources contained in the underlying API # response. If page streaming is performed per-resource, this # parameter does not affect the return value. If page streaming is # performed per-page, this determines the maximum number of # resources in a page. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>] # An enumerable of Google::Cloud::Kms::V1::CryptoKeyVersion instances. # See Google::Gax::PagedEnumerable documentation for other # operations such as per-page iteration or access to the response # object. # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # Iterate over all results. # key_management_service_client.list_crypto_key_versions(formatted_parent).each do |element| # # Process element. # end # # # Or iterate over results one page at a time. # key_management_service_client.list_crypto_key_versions(formatted_parent).each_page do |page| # # Process each page at a time. # page.each do |element| # # Process element. # end # end def list_crypto_key_versions \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest) @list_crypto_key_versions.call(req, , &block) end # Returns metadata for a given {Google::Cloud::Kms::V1::KeyRing KeyRing}. # # @param name [String] # The {Google::Cloud::Kms::V1::KeyRing#name name} of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to get. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::KeyRing] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::KeyRing] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # response = key_management_service_client.get_key_ring(formatted_name) def get_key_ring \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetKeyRingRequest) @get_key_ring.call(req, , &block) end # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKey CryptoKey}, as well as its # {Google::Cloud::Kms::V1::CryptoKey#primary primary} {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}. # # @param name [String] # The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to get. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # response = key_management_service_client.get_crypto_key(formatted_name) def get_crypto_key \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyRequest) @get_crypto_key.call(req, , &block) end # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}. # # @param name [String] # The {Google::Cloud::Kms::V1::CryptoKeyVersion#name name} of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to get. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]") # response = key_management_service_client.get_crypto_key_version(formatted_name) def get_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest) @get_crypto_key_version.call(req, , &block) end # Create a new {Google::Cloud::Kms::V1::KeyRing KeyRing} in a given Project and Location. # # @param parent [String] # Required. The resource name of the location associated with the # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format +projects/*/locations/*+. # @param key_ring_id [String] # Required. It must be unique within a location and match the regular # expression +[a-zA-Z0-9_-]{1,63}+ # @param key_ring [Google::Cloud::Kms::V1::KeyRing | Hash] # A {Google::Cloud::Kms::V1::KeyRing KeyRing} with initial field values. # A hash of the same form as `Google::Cloud::Kms::V1::KeyRing` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::KeyRing] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::KeyRing] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path("[PROJECT]", "[LOCATION]") # # # TODO: Initialize +key_ring_id+: # key_ring_id = '' # # # TODO: Initialize +key_ring+: # key_ring = {} # response = key_management_service_client.create_key_ring(formatted_parent, key_ring_id, key_ring) def create_key_ring \ parent, key_ring_id, key_ring, options: nil, &block req = { parent: parent, key_ring_id: key_ring_id, key_ring: key_ring }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateKeyRingRequest) @create_key_ring.call(req, , &block) end # Create a new {Google::Cloud::Kms::V1::CryptoKey CryptoKey} within a {Google::Cloud::Kms::V1::KeyRing KeyRing}. # # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose} is required. # # @param parent [String] # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the KeyRing associated with the # {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}. # @param crypto_key_id [String] # Required. It must be unique within a KeyRing and match the regular # expression +[a-zA-Z0-9_-]{1,63}+ # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey | Hash] # A {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with initial field values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKey` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # crypto_key_id = "my-app-key" # purpose = :ENCRYPT_DECRYPT # seconds = 2147483647 # next_rotation_time = { seconds: seconds } # seconds_2 = 604800 # rotation_period = { seconds: seconds_2 } # crypto_key = { # purpose: purpose, # next_rotation_time: next_rotation_time, # rotation_period: rotation_period # } # response = key_management_service_client.create_crypto_key(formatted_parent, crypto_key_id, crypto_key) def create_crypto_key \ parent, crypto_key_id, crypto_key, options: nil, &block req = { parent: parent, crypto_key_id: crypto_key_id, crypto_key: crypto_key }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyRequest) @create_crypto_key.call(req, , &block) end # Create a new {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}. # # The server will assign the next sequential id. If unset, # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} will be set to # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED}. # # @param parent [String] # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} associated with # the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}. # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion | Hash] # A {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with initial field values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKeyVersion` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # TODO: Initialize +crypto_key_version+: # crypto_key_version = {} # response = key_management_service_client.create_crypto_key_version(formatted_parent, crypto_key_version) def create_crypto_key_version \ parent, crypto_key_version, options: nil, &block req = { parent: parent, crypto_key_version: crypto_key_version }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest) @create_crypto_key_version.call(req, , &block) end # Update a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}. # # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey | Hash] # {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with updated values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKey` # can also be provided. # @param update_mask [Google::Protobuf::FieldMask | Hash] # Required list of fields to be updated in this request. # A hash of the same form as `Google::Protobuf::FieldMask` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # # # TODO: Initialize +crypto_key+: # crypto_key = {} # # # TODO: Initialize +update_mask+: # update_mask = {} # response = key_management_service_client.update_crypto_key(crypto_key, update_mask) def update_crypto_key \ crypto_key, update_mask, options: nil, &block req = { crypto_key: crypto_key, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyRequest) @update_crypto_key.call(req, , &block) end # Update a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}'s metadata. # # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} may be changed between # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED} and # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED} using this # method. See {Google::Cloud::Kms::V1::KeyManagementService::DestroyCryptoKeyVersion DestroyCryptoKeyVersion} and {Google::Cloud::Kms::V1::KeyManagementService::RestoreCryptoKeyVersion RestoreCryptoKeyVersion} to # move between other states. # # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion | Hash] # {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with updated values. # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKeyVersion` # can also be provided. # @param update_mask [Google::Protobuf::FieldMask | Hash] # Required list of fields to be updated in this request. # A hash of the same form as `Google::Protobuf::FieldMask` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # # # TODO: Initialize +crypto_key_version+: # crypto_key_version = {} # # # TODO: Initialize +update_mask+: # update_mask = {} # response = key_management_service_client.update_crypto_key_version(crypto_key_version, update_mask) def update_crypto_key_version \ crypto_key_version, update_mask, options: nil, &block req = { crypto_key_version: crypto_key_version, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest) @update_crypto_key_version.call(req, , &block) end # Encrypts data, so that it can only be recovered by a call to {Google::Cloud::Kms::V1::KeyManagementService::Decrypt Decrypt}. # # @param name [String] # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} or {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} # to use for encryption. # # If a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} is specified, the server will use its # {Google::Cloud::Kms::V1::CryptoKey#primary primary version}. # @param plaintext [String] # Required. The data to encrypt. Must be no larger than 64KiB. # @param additional_authenticated_data [String] # Optional data that, if specified, must also be provided during decryption # through {Google::Cloud::Kms::V1::DecryptRequest#additional_authenticated_data DecryptRequest#additional_authenticated_data}. Must be no # larger than 64KiB. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::EncryptResponse] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::EncryptResponse] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY_PATH]") # # # TODO: Initialize +plaintext+: # plaintext = '' # response = key_management_service_client.encrypt(formatted_name, plaintext) def encrypt \ name, plaintext, additional_authenticated_data: nil, options: nil, &block req = { name: name, plaintext: plaintext, additional_authenticated_data: additional_authenticated_data }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::EncryptRequest) @encrypt.call(req, , &block) end # Decrypts data that was protected by {Google::Cloud::Kms::V1::KeyManagementService::Encrypt Encrypt}. # # @param name [String] # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to use for decryption. # The server will choose the appropriate version. # @param ciphertext [String] # Required. The encrypted data originally returned in # {Google::Cloud::Kms::V1::EncryptResponse#ciphertext EncryptResponse#ciphertext}. # @param additional_authenticated_data [String] # Optional data that must match the data originally supplied in # {Google::Cloud::Kms::V1::EncryptRequest#additional_authenticated_data EncryptRequest#additional_authenticated_data}. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::DecryptResponse] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::DecryptResponse] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # TODO: Initialize +ciphertext+: # ciphertext = '' # response = key_management_service_client.decrypt(formatted_name, ciphertext) def decrypt \ name, ciphertext, additional_authenticated_data: nil, options: nil, &block req = { name: name, ciphertext: ciphertext, additional_authenticated_data: additional_authenticated_data }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DecryptRequest) @decrypt.call(req, , &block) end # Update the version of a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} that will be used in {Google::Cloud::Kms::V1::KeyManagementService::Encrypt Encrypt} # # @param name [String] # The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to update. # @param crypto_key_version_id [String] # The id of the child {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use as primary. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKey] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]") # # # TODO: Initialize +crypto_key_version_id+: # crypto_key_version_id = '' # response = key_management_service_client.update_crypto_key_primary_version(formatted_name, crypto_key_version_id) def update_crypto_key_primary_version \ name, crypto_key_version_id, options: nil, &block req = { name: name, crypto_key_version_id: crypto_key_version_id }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest) @update_crypto_key_primary_version.call(req, , &block) end # Schedule a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} for destruction. # # Upon calling this method, {Google::Cloud::Kms::V1::CryptoKeyVersion#state CryptoKeyVersion#state} will be set to # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED} # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be set to a time 24 # hours in the future, at which point the {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} # will be changed to # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROYED DESTROYED}, and the key # material will be irrevocably destroyed. # # Before the {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} is reached, # {Google::Cloud::Kms::V1::KeyManagementService::RestoreCryptoKeyVersion RestoreCryptoKeyVersion} may be called to reverse the process. # # @param name [String] # The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to destroy. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]") # response = key_management_service_client.destroy_crypto_key_version(formatted_name) def destroy_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest) @destroy_crypto_key_version.call(req, , &block) end # Restore a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in the # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED}, # state. # # Upon restoration of the CryptoKeyVersion, {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} # will be set to {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED}, # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be cleared. # # @param name [String] # The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to restore. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Cloud::Kms::V1::CryptoKeyVersion] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]") # response = key_management_service_client.restore_crypto_key_version(formatted_name) def restore_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest) @restore_crypto_key_version.call(req, , &block) end # Sets the access control policy on the specified resource. Replaces any # existing policy. # # @param resource [String] # REQUIRED: The resource for which the policy is being specified. # +resource+ is usually specified as a path. For example, a Project # resource is specified as +projects/{project}+. # @param policy [Google::Iam::V1::Policy | Hash] # REQUIRED: The complete policy to be applied to the +resource+. The size of # the policy is limited to a few 10s of KB. An empty policy is a # valid policy but certain Cloud Platform services (such as Projects) # might reject them. # A hash of the same form as `Google::Iam::V1::Policy` # can also be provided. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Iam::V1::Policy] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Iam::V1::Policy] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # # # TODO: Initialize +policy+: # policy = {} # response = key_management_service_client.set_iam_policy(formatted_resource, policy) def set_iam_policy \ resource, policy, options: nil, &block req = { resource: resource, policy: policy }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest) @set_iam_policy.call(req, , &block) end # Gets the access control policy for a resource. # Returns an empty policy if the resource exists and does not have a policy # set. # # @param resource [String] # REQUIRED: The resource for which the policy is being requested. # +resource+ is usually specified as a path. For example, a Project # resource is specified as +projects/{project}+. # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Iam::V1::Policy] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Iam::V1::Policy] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # response = key_management_service_client.get_iam_policy(formatted_resource) def get_iam_policy \ resource, options: nil, &block req = { resource: resource }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest) @get_iam_policy.call(req, , &block) end # Returns permissions that a caller has on the specified resource. # If the resource does not exist, this will return an empty set of # permissions, not a NOT_FOUND error. # # @param resource [String] # REQUIRED: The resource for which the policy detail is being requested. # +resource+ is usually specified as a path. For example, a Project # resource is specified as +projects/{project}+. # @param permissions [Array<String>] # The set of permissions to check for the +resource+. Permissions with # wildcards (such as '*' or 'storage.*') are not allowed. For more # information see # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). # @param options [Google::Gax::CallOptions] # Overrides the default settings for this call, e.g, timeout, # retries, etc. # @yield [result, operation] Access the result along with the RPC operation # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse] # @yieldparam operation [GRPC::ActiveCall::Operation] # @return [Google::Iam::V1::TestIamPermissionsResponse] # @raise [Google::Gax::GaxError] if the RPC is aborted. # @example # require "google/cloud/kms" # # key_management_service_client = Google::Cloud::Kms.new(version: :V1) # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]") # # # TODO: Initialize +permissions+: # permissions = [] # response = key_management_service_client.test_iam_permissions(formatted_resource, permissions) def \ resource, , options: nil, &block req = { resource: resource, permissions: }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest) @test_iam_permissions.call(req, , &block) end end |
Class Method Details
.crypto_key_path(project, location, key_ring, crypto_key) ⇒ String
Returns a fully-qualified crypto_key resource name string.
161 162 163 164 165 166 167 168 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 161 def self.crypto_key_path project, location, key_ring, crypto_key CRYPTO_KEY_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key" => crypto_key ) end |
.crypto_key_path_path(project, location, key_ring, crypto_key_path) ⇒ String
Returns a fully-qualified crypto_key_path resource name string.
135 136 137 138 139 140 141 142 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 135 def self.crypto_key_path_path project, location, key_ring, crypto_key_path CRYPTO_KEY_PATH_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key_path" => crypto_key_path ) end |
.crypto_key_version_path(project, location, key_ring, crypto_key, crypto_key_version) ⇒ String
Returns a fully-qualified crypto_key_version resource name string.
177 178 179 180 181 182 183 184 185 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 177 def self.crypto_key_version_path project, location, key_ring, crypto_key, crypto_key_version CRYPTO_KEY_VERSION_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring, :"crypto_key" => crypto_key, :"crypto_key_version" => crypto_key_version ) end |
.key_ring_path(project, location, key_ring) ⇒ String
Returns a fully-qualified key_ring resource name string.
121 122 123 124 125 126 127 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 121 def self.key_ring_path project, location, key_ring KEY_RING_PATH_TEMPLATE.render( :"project" => project, :"location" => location, :"key_ring" => key_ring ) end |
.location_path(project, location) ⇒ String
Returns a fully-qualified location resource name string.
148 149 150 151 152 153 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 148 def self.location_path project, location LOCATION_PATH_TEMPLATE.render( :"project" => project, :"location" => location ) end |
Instance Method Details
#create_crypto_key(parent, crypto_key_id, crypto_key, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Create a new CryptoKey within a KeyRing.
CryptoKey#purpose is required.
801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 801 def create_crypto_key \ parent, crypto_key_id, crypto_key, options: nil, &block req = { parent: parent, crypto_key_id: crypto_key_id, crypto_key: crypto_key }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyRequest) @create_crypto_key.call(req, , &block) end |
#create_crypto_key_version(parent, crypto_key_version, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Create a new CryptoKeyVersion in a CryptoKey.
The server will assign the next sequential id. If unset, state will be set to ENABLED.
847 848 849 850 851 852 853 854 855 856 857 858 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 847 def create_crypto_key_version \ parent, crypto_key_version, options: nil, &block req = { parent: parent, crypto_key_version: crypto_key_version }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest) @create_crypto_key_version.call(req, , &block) end |
#create_key_ring(parent, key_ring_id, key_ring, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::KeyRing
Create a new KeyRing in a given Project and Location.
746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 746 def create_key_ring \ parent, key_ring_id, key_ring, options: nil, &block req = { parent: parent, key_ring_id: key_ring_id, key_ring: key_ring }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateKeyRingRequest) @create_key_ring.call(req, , &block) end |
#decrypt(name, ciphertext, additional_authenticated_data: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::DecryptResponse
Decrypts data that was protected by Encrypt.
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1028 def decrypt \ name, ciphertext, additional_authenticated_data: nil, options: nil, &block req = { name: name, ciphertext: ciphertext, additional_authenticated_data: additional_authenticated_data }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DecryptRequest) @decrypt.call(req, , &block) end |
#destroy_crypto_key_version(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Schedule a CryptoKeyVersion for destruction.
Upon calling this method, CryptoKeyVersion#state will be set to DESTROY_SCHEDULED and destroy_time will be set to a time 24 hours in the future, at which point the state will be changed to DESTROYED, and the key material will be irrevocably destroyed.
Before the destroy_time is reached, RestoreCryptoKeyVersion may be called to reverse the process.
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1110 def destroy_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest) @destroy_crypto_key_version.call(req, , &block) end |
#encrypt(name, plaintext, additional_authenticated_data: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::EncryptResponse
Encrypts data, so that it can only be recovered by a call to Decrypt.
984 985 986 987 988 989 990 991 992 993 994 995 996 997 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 984 def encrypt \ name, plaintext, additional_authenticated_data: nil, options: nil, &block req = { name: name, plaintext: plaintext, additional_authenticated_data: additional_authenticated_data }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::EncryptRequest) @encrypt.call(req, , &block) end |
#get_crypto_key(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
672 673 674 675 676 677 678 679 680 681 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 672 def get_crypto_key \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyRequest) @get_crypto_key.call(req, , &block) end |
#get_crypto_key_version(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Returns metadata for a given CryptoKeyVersion.
702 703 704 705 706 707 708 709 710 711 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 702 def get_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest) @get_crypto_key_version.call(req, , &block) end |
#get_iam_policy(resource, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::Policy
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1225 def get_iam_policy \ resource, options: nil, &block req = { resource: resource }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest) @get_iam_policy.call(req, , &block) end |
#get_key_ring(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::KeyRing
Returns metadata for a given KeyRing.
641 642 643 644 645 646 647 648 649 650 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 641 def get_key_ring \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetKeyRingRequest) @get_key_ring.call(req, , &block) end |
#list_crypto_key_versions(parent, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>
Lists CryptoKeyVersions.
609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 609 def list_crypto_key_versions \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest) @list_crypto_key_versions.call(req, , &block) end |
#list_crypto_keys(parent, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>
Lists CryptoKeys.
554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 554 def list_crypto_keys \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeysRequest) @list_crypto_keys.call(req, , &block) end |
#list_key_rings(parent, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>
Lists KeyRings.
499 500 501 502 503 504 505 506 507 508 509 510 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 499 def list_key_rings \ parent, page_size: nil, options: nil, &block req = { parent: parent, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListKeyRingsRequest) @list_key_rings.call(req, , &block) end |
#restore_crypto_key_version(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Restore a CryptoKeyVersion in the DESTROY_SCHEDULED, state.
Upon restoration of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will be cleared.
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1146 def restore_crypto_key_version \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest) @restore_crypto_key_version.call(req, , &block) end |
#set_iam_policy(resource, policy, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::Policy
Sets the access control policy on the specified resource. Replaces any existing policy.
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1189 def set_iam_policy \ resource, policy, options: nil, &block req = { resource: resource, policy: policy }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest) @set_iam_policy.call(req, , &block) end |
#test_iam_permissions(resource, permissions, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::TestIamPermissionsResponse
Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1267 def \ resource, , options: nil, &block req = { resource: resource, permissions: }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest) @test_iam_permissions.call(req, , &block) end |
#update_crypto_key(crypto_key, update_mask, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Update a CryptoKey.
890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 890 def update_crypto_key \ crypto_key, update_mask, options: nil, &block req = { crypto_key: crypto_key, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyRequest) @update_crypto_key.call(req, , &block) end |
#update_crypto_key_primary_version(name, crypto_key_version_id, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKey
Update the version of a CryptoKey that will be used in Encrypt
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 1067 def update_crypto_key_primary_version \ name, crypto_key_version_id, options: nil, &block req = { name: name, crypto_key_version_id: crypto_key_version_id }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest) @update_crypto_key_primary_version.call(req, , &block) end |
#update_crypto_key_version(crypto_key_version, update_mask, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Kms::V1::CryptoKeyVersion
Update a CryptoKeyVersion's metadata.
state may be changed between ENABLED and DISABLED using this method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to move between other states.
939 940 941 942 943 944 945 946 947 948 949 950 |
# File 'lib/google/cloud/kms/v1/key_management_service_client.rb', line 939 def update_crypto_key_version \ crypto_key_version, update_mask, options: nil, &block req = { crypto_key_version: crypto_key_version, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest) @update_crypto_key_version.call(req, , &block) end |