コード例 #1
0
 public KmsDataProtectionProvider(
     string googleProjectId,
     string keyRingLocation,
     string keyRingId)
 {
     _googleProjectId = googleProjectId ??
                        throw new ArgumentNullException(nameof(googleProjectId));
     _keyRingLocation = keyRingLocation ??
                        throw new ArgumentNullException(nameof(keyRingLocation));
     _keyRingId = keyRingId ??
                  throw new ArgumentNullException(nameof(keyRingId));
     _kms         = KeyManagementServiceClient.Create();
     _keyRingName = new KeyRingName(_googleProjectId,
                                    _keyRingLocation, _keyRingId);
     try
     {
         // Create the key ring.
         _kms.CreateKeyRing(
             new LocationName(_googleProjectId, _keyRingLocation),
             _keyRingId, new KeyRing());
     }
     catch (Grpc.Core.RpcException e)
         when(e.StatusCode == StatusCode.AlreadyExists)
         {
             // Already exists.  Ok.
         }
 }
コード例 #2
0
    public KeyRing CreateKeyRing(string keyRingId)
    {
        KeyManagementServiceClient client = KeyManagementServiceClient.Create();

        return(client.CreateKeyRing(new CreateKeyRingRequest
        {
            ParentAsLocationName = LocationName,
            KeyRingId = keyRingId,
        }));
    }
コード例 #3
0
        // [END kms_list_cryptokeys]

        // [START kms_create_keyring]
        public static void CreateKeyRing(string projectId, string locationId, string keyRingId)
        {
            KeyManagementServiceClient client = KeyManagementServiceClient.Create();

            // The location in which to create the key ring.
            LocationName locationName = new LocationName(projectId, locationId);

            // Initial values for the KeyRing (currently unused).
            KeyRing keyRing = new KeyRing();

            KeyRing result = client.CreateKeyRing(locationName, keyRingId, keyRing);

            Console.Write($"Created Key Ring: {result.Name}");
        }
コード例 #4
0
    public KeyRing CreateKeyRing(
        string projectId = "my-project", string locationId = "us-east1",
        string id        = "my-key-ring")
    {
        // Create the client.
        KeyManagementServiceClient client = KeyManagementServiceClient.Create();

        // Build the parent location name.
        LocationName locationName = new LocationName(projectId, locationId);

        // Build the key ring.
        KeyRing keyRing = new KeyRing {
        };

        // Call the API.
        KeyRing result = client.CreateKeyRing(locationName, id, keyRing);

        // Return the result.
        return(result);
    }