# Key Management Service (KMS)

# Install library

### Install
```php
$ pip install vcc-kms-client
```

## Table of contents
1. [Usage](#usage)
   - [Create KMS Key](#create-kms-key)
   - [Generate Data Key Pair](#generate-data-key-pair)
   - [Generate Data Key](#generate-data-key)
   - [Encrypt](#encrypt)
   - [Decrypt](#decrypt)
   - [Encrypt With Data Key](#encrypt-with-data-key)
   - [Decrypt With Data Key](#decrypt-with-data-key)
   - [Encrypt With Data Key Pair](#encrypt-with-data-key-pair)
   - [Decrypt With Data Key Pair](#decrypt-with-data-key-pair)
   - [Update Alias](#update-alias)
   - [Delete Alias](#delete-alias)
   - [Describe KMS Key](#describe-kms-key)
   - [Disable KMS Key](#disable-kms-key)
   - [Enable KMS Key](#enable-kms-key)
   - [Delete KMS Key](#delete-kms-key)
   - [List KMS Key By Alias](#list-kms-key-by-alias)
   - [List KMS Key](#list-kms-key)
   - [Update Description Key](#update-description-key)
   - [Sign](#sign)
   - [Verify](#verify)

## Usage
Add security_file.json into project

### Create KMS Key
This function generate KMS key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm
from src.vcc_kms_client.models.create_kms_key_request import CreateKMSKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = CreateKMSKeyRequest(None, None, algorithm.AES_256)
print(kms.create_key(request))
```
Response
```text
key_id = 01H0MM0QJSEMZ2ZX41AX5DJ2RJ, alias = None, algorithm = None, state = ENABLED, description = AES_256
```

### Generate Data Key Pair
This function generate data key pair, create plaintext private data key, encrypt private data key and plaintext public data key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm
from src.vcc_kms_client.models.generate_data_key_pair_request import GenerateDataKeyPairRequest

from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = GenerateDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', algorithm.RSA_2048)
print(kms.generate_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, algorithm = RSA_2048, encrypt_private_data_key =  , plaintext_private_data_key =  , plaintext_public_data_key = MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAka80DBzK69Vo+ZWSTtjt1ltDo5DdMh6bqBzBakqwcGBLBRaPc4jqFJJ7eGg38pBwWkKQ4ab3kJCe4MiYcbjeL1hTeAaNFsT2QZyausUF+hT7lOb2pbXrmxKNbFtnyGAh10/lKVde85qHzTM+fofurVZpTRPIRn8T30MOXBofen5cwljcEgk13loJNuFkQZbvg0adv9s6iQiSZjSHd2nXmHbnWtXl7W4WGltP7AZC24XRf8MhmBLTjQPCDmNOGYL02UWxa+4jJ5utAdZNpTANYVchC07Sa/teXQZ8HNYbtzltqJc/VoT72h63eAytM4M/XIJeCX44nw3eN7YQ30l80wIDAQAB
```

### Generate Data Key
This function generate data key, create plaintext secret data key and encrypt secret data key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm
from src.vcc_kms_client.models.generate_data_key_request import GenerateDataKeyRequest

from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = GenerateDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', algorithm.AES_256)
print(kms.generate_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, algorithm = AES_256, plaintext_data_key = k1lvvTPcKOvXF4I1LPZE2XnKlcyyAQJspIQgWXdzjXo=, encrypt_data_key = wdXCZMn2ECxuL2npx9eXO5BwDVmW0PyqoCumo82GiJfHpNqaGYRSpDl3CchfOzqa
```

### Encrypt
This function encrypt data directly with KMS key
#### Encrypt single text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.encrypt_request import EncryptRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EncryptRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', 'cuong dep zai', content_type.SINGLE_STRING)
print(kms.encrypt(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = LoujTFUY5aELdmBB6b2N0g==, algorithm = AES_256
```
#### Encrypt list text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.encrypt_request import EncryptRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EncryptRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', ['cuong dep zai', 'asdasdasd'], content_type.LIST_STRING)
print(kms.encrypt(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['LoujTFUY5aELdmBB6b2N0g==', 's11DGSnLf6hUNHYNB6rwFQ=='], algorithm = AES_256
```
#### Encrypt list json

```python
import json

from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.encrypt_request import EncryptRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
x = {
   "name": "John",
   "age": 30,
   "city": "New York"
}
y = json.dumps(x)
request = EncryptRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [y], content_type.LIST_JSON_OBJECT)
print(kms.encrypt(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['{"city":"PFdV2PVgBbcQp+mQyd4usQ==","name":"IYMUmLTiP5rZFYA9zKIWTA==","age":"vBzZWDM9u3Fkt0yVQCl7Ow=="}'], algorithm = AES_256
```

### Decrypt
This function decrypt data directly with KMS key
#### Decrypt single text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_request import DecryptRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DecryptRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', 'LoujTFUY5aELdmBB6b2N0g==', content_type.SINGLE_STRING)
print(kms.decrypt(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = cuong dep zai
```
#### Decrypt list text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_request import DecryptRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DecryptRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', ['LoujTFUY5aELdmBB6b2N0g==', 's11DGSnLf6hUNHYNB6rwFQ=='],
                         content_type.LIST_STRING)
print(kms.decrypt(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['cuong dep zai', 'asdasdasd']
```
#### Decrypt list json

```python
import json

from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_request import DecryptRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
x = {
   "name": "IYMUmLTiP5rZFYA9zKIWTA==",
   "age": "vBzZWDM9u3Fkt0yVQCl7Ow==",
   "city": "PFdV2PVgBbcQp+mQyd4usQ=="
}
y = json.dumps(x)
request = DecryptRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [y], content_type.LIST_JSON_OBJECT)
print(kms.decrypt(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['{"city":"New York","name":"John","age":"30"}']
```

### Encrypt With Data Key
This function encrypt data with data key
#### Encrypt single text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm, content_type
from src.vcc_kms_client.models.encrypt_with_data_key_request import EncryptWithDataKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EncryptWithDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', 'cuong dep zai', algorithm.AES_256,
                                    content_type.SINGLE_STRING)
print(kms.encrypt_with_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = 7CqNRImiu2/DdnNoosdYnqYG4pzizC4EIzqDwbb2FUF3yNeSyOkq2yR9GlJinKu8xRXF/29i+Ep4VZdpOs85ap6JVyYeR+D6cBfPOLrUVJvNAXB2rnOPKC8qgMIO4AJf4cMKJ1HygepC62fE9wkIzhe1/+LOHiVp1RmEmQ9cqF4=, algorithm = AES_256
```
#### Encrypt list text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm, content_type
from src.vcc_kms_client.models.encrypt_with_data_key_request import EncryptWithDataKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EncryptWithDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', ['cuong dep zai', 'asdasdasd'], algorithm.AES_256,
                                    content_type.LIST_STRING)
print(kms.encrypt_with_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['7CqNRImiu2/DdnNoosdYnpuqkt8JzDdMdBjxaXC+X1TERkaNQuGRdW0K6fNGV3j0uPdNhQgCoVSKx8xfVqFJRn2rbzqZLo+z/GdBBg8+OgUQay+tLHeSx6LcITc+RQAQbXgC3FORp3FT/pmUrBd5OztNna8gSg1XOBTlp47r/Aw=', '7CqNRImiu2/DdnNoosdYnlTzfvCjzX9FzKR2FuNbQwQ9aRMZg8YNMNKI0sMjIcXnObZ7pvcUxvPTBr5CnLs7htBxDqM+VM7QFP3wogqgC8xUoyfbqXSQpDttVnRR7sr6dtXg2gnbWlBLzdjotDZulBPcF5w+DfukqKqldFcUN8M='], algorithm = AES_256
```
#### Encrypt list json

```python
import json

from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm, content_type
from src.vcc_kms_client.models.encrypt_with_data_key_request import EncryptWithDataKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
x = {
   "name": "John",
   "age": 30,
   "city": "New York"
}
y = json.dumps(x)
request = EncryptWithDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [y], algorithm.AES_256, content_type.LIST_JSON_OBJECT)
print(kms.encrypt_with_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['{"city":"7CqNRImiu2/DdnNoosdYnsJptvZLDfhartHVhvwiPafXjXYRN6MBhINgU0PbfVAyHmrb4YsGvNZKchvHDMfSs/9+fX/fqOmreSbzIt/N3a0aKlOhbbKQOWjDm9/yFBLFiFMAMqVPyoZzFSa2KbO5nZAFLkWEUMxg9lpqzJKWSdA=","name":"7CqNRImiu2/DdnNoosdYnqQVa8HtVXmExXrPi9eEF29UzAialm4BqNSapkM3sFyXHEhaS6zJ+E9gQQPtCtrpdssHaAkV9jxCDuB6iR0Xewzn8y3nb61aYkwxJrMtStMDNsAa4qWuTagAtvpdeb/4oQ5diiP/tECaPQXN2tYyxfQ=","age":"7CqNRImiu2/DdnNoosdYnjjbATsiDJ0i4xcPQwRt567k+Y/MRd9yfI4rJDYANr8SyQ/mrKp8dogDyksie80Wf5vB2naf34mJ88jmU6YyCI44Wj0jV+z+yb9wh07zgNmcMNZDsMDl90dOUtH4x1Mp6MMt/DIvcmwgg9FOX+IxMaU="}'], algorithm = AES_256
```

### Decrypt With Data Key
This function decrypt data with data key
#### Decrypt single text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_with_data_key_request import DecryptWithDataKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DecryptWithDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS',
                                    '7CqNRImiu2/DdnNoosdYnsBE5OG9536Cm3i1ulWm8f4ZcBUt4w4C9v3CI+lk2q/d8QJHJWzf9j0ljhvsH4L+/6uYa6pItvBwNNmCzhoV6m/ZyRMsheVwtZNxILVTs9qMx0ma4bivTvvF+DjJj2X2q6AZOVKJ0v2QsD78Tk/yOUc=',
                                    content_type.SINGLE_STRING)
print(kms.decrypt_with_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = cuong dep zai
```
#### Decrypt list text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_with_data_key_request import DecryptWithDataKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DecryptWithDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [
   '7CqNRImiu2/DdnNoosdYnmtjitw05f0yj+ZaVggwGZbtxYKlG1dpnEylu+yL+nJFlJceXbptMvLtoX2iauXUfUGna7kY1JtJHoJbMIKYRBY7lBXMUimVH60de4I6gcaLl3T1pBZcs+kXOkpggIwSaDG880ExuSv9CFcRFUUEAvc='],
                                    content_type.LIST_STRING)
print(kms.decrypt_with_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['cuong dep zai']
```
#### Decrypt list json

```python
import json

from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_with_data_key_request import DecryptWithDataKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
x = {
   "name": "7CqNRImiu2/DdnNoosdYnpe87Xr+x7AOLNni46fKzsKVuG2YKgz6lD5pbdkgO94dmNLB9O1/MDaMhoXvJvqE/8JdmKCicHEygizphFWleP4JSM8sdxYmI0B2fVZhT3lqlfUs60Lfkw1ldGeCbx1w85W335RrpjBI7O2kJXaWIdI=",
   "age": "7CqNRImiu2/DdnNoosdYnnxYyyMhVU9FGFfC5pEJm6VW2SeLpYoHzVtGUF87NXwj/k2MslgSZKYVGZ3EhrisIBC1tFR5AeL97WsUClSP989Es3HlTIPJODCFRZngjdjHpVIFbXrfzZGU2yqlxLtJfe44h7BWckg3HFRVzq1Hpw4=",
   "city": "7CqNRImiu2/DdnNoosdYnkcWN01M9TuSTp1iBKr4tkvfma27HtX84d4BZSdXzXx4o550Dd/iW6yqVB+NMJ0HE5r439gaqxcmojf5zF8OAszJzqniNRDJZn7t1DtnRp3Yzbebj3/ErW7t2EDicjae5O4NNgrTZc3Dap9bB2vMSSU="
}
y = json.dumps(x)
request = DecryptWithDataKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [y], content_type.LIST_JSON_OBJECT)
print(kms.decrypt_with_data_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['{"city":"New York","name":"John","age":"30"}']
```

### Encrypt With Data Key Pair
This function encrypt data with data key pair
#### Encrypt single text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm, content_type
from src.vcc_kms_client.models.encrypt_with_data_key_pair_request import EncryptWithDataKeyPairRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EncryptWithDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', 'cuong dep zai', algorithm.RSA_2048,
                                        content_type.SINGLE_STRING)
print(kms.encrypt_with_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output =  , algorithm = RSA_2048
```
#### Encrypt list text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm, content_type
from src.vcc_kms_client.models.encrypt_with_data_key_pair_request import EncryptWithDataKeyPairRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EncryptWithDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', ['cuong dep zai'], algorithm.RSA_2048,
                                        content_type.LIST_STRING)
print(kms.encrypt_with_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = [' '], algorithm = RSA_2048
```
#### Encrypt list json

```python
import json

from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import algorithm, content_type
from src.vcc_kms_client.models.encrypt_with_data_key_pair_request import EncryptWithDataKeyPairRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
x = {
   "name": "John"
}
y = json.dumps(x)
request = EncryptWithDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [y], algorithm.RSA_2048,
                                        content_type.LIST_JSON_OBJECT)
print(kms.encrypt_with_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['{"name":" "}'], algorithm = RSA_2048
```

### Decrypt With Data Key Pair
This function decrypt data with data key pair
#### Decrypt single text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_with_data_key_pair_request import DecryptWithDataKeyPairRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DecryptWithDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS',
                                        ' ',
                                        content_type.SINGLE_STRING)
print(kms.decrypt_with_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = cuong dep zai
```
#### Decrypt list text

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_with_data_key_pair_request import DecryptWithDataKeyPairRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DecryptWithDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [
   ' '],
                                        content_type.LIST_STRING)
print(kms.decrypt_with_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['cuong dep zai']
```
#### Decrypt list json

```python
import json

from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import content_type
from src.vcc_kms_client.models.decrypt_with_data_key_pair_request import DecryptWithDataKeyPairRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
x = {
   "name": " "
}
y = json.dumps(x)
request = DecryptWithDataKeyPairRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', [y], content_type.LIST_JSON_OBJECT)
print(kms.decrypt_with_data_key_pair(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, output = ['{"name":"John"}']
```

### Update Alias
This function update alias key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.update_alias_key_request import UpdateAliasKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = UpdateAliasKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', 'ssss dep zai')
print(kms.update_alias_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, alias = ssss dep zai
```

### Delete Alias
This function delete alias key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.delete_alias_key_request import DeleteAliasKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DeleteAliasKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS')
print(kms.delete_alias_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS
```

### Describe KMS Key
This function view KMS Key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.describe_kms_key_request import DescribeKMSKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DescribeKMSKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS')
print(kms.describe_kms_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, alias = dsafasfasfasasfasf, algorithm = None, state = ENABLED, description = AES_256
```

### Disable KMS Key
This function disable KMS key, when in this state Disable, KMS Key will not be able to use the encrypted, decrypted and generated

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.disable_kms_key_request import DisableKMSKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DisableKMSKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS')
print(kms.disable_kms_key(request))
```
Response
```text
key_id = 01H0FB74RH8Z3C9CP696ACPC1G, state = DISABLED
```

### Enable KMS Key
This function enable KMS key, when in this state Enable, KMS Key will be able to use the encrypted, decrypted and generated

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.enable_kms_key_request import EnableKMSKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = EnableKMSKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS')
print(kms.enable_kms_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, state = ENABLED
```

### Delete KMS Key
This function delete KMS, key will not be deleted immediately but will be deleted after 7 days

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.delete_kms_key_request import DeleteKMSKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = DeleteKMSKeyRequest('01H0PDX0YRWPEY3GRR2D833E09')
print(kms.delete_kms_key(request))
```
Response
```text
key_id = 01H0PDX0YRWPEY3GRR2D833E09, state = SCHEDULED_DELETION
```

### List KMS Key By Alias
This function list KMS Key by alias when the user has permission view those keys

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.list_kms_key_by_alias_request import ListKMSKeyByAliasRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = ListKMSKeyByAliasRequest(1, 0, 'cuong dep zai')
print(kms.list_key_by_alias(request).keys[0])
```
Response
```text
key_id = 01GZJT8VX8ZD3TVNN0VZXD3J69, alias = dsafasfasfasasfasf, algorithm = cuong dep zai, state = ENABLED, description = AES_256
```

### List KMS Key
This function list key when the user has permission view those keys

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.list_kms_key_request import ListKMSKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = ListKMSKeyRequest(3, 0)
for key in kms.list_key(request).keys:
   print(key)
```
Response
```text
key_id = 01GVD5HP5NSS0AZAX9D4E6Y1RX, alias = None, algorithm = cuongdepzai3, state = ENABLED, description = AES_256
key_id = 01GVD5JGAX1ESW09PN3BFQ7XBE, alias = None, algorithm = cuongdepzai4, state = ENABLED, description = RSA_2048
key_id = 01GVD5MX66PRTEJGD08ZTPXS4S, alias = None, algorithm = cuongdepzai5, state = ENABLED, description = RSA_3072
```

### Update Description Key
This function update description key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models.update_description_key_request import UpdateDescriptionKeyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = UpdateDescriptionKeyRequest('01GZZWTJYTNRGEQ8YMQQ7H6KMS', 'dsafasfasfasasfasf')
print(kms.update_description_key(request))
```
Response
```text
key_id = 01GZZWTJYTNRGEQ8YMQQ7H6KMS, description = dsafasfasfasasfasf
```

### Sign
This function sign message with KMS key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import sign_algorithm
from src.vcc_kms_client.models.sign_request import SignRequest

from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = SignRequest('01GZX850ZW3W4HC40T1ZX6V8NA', 'cuong dep zai', sign_algorithm.SHA512_RSA)
print(kms.sign(request))
```
Response
```text
key_id = 01GZX850ZW3W4HC40T1ZX6V8NA, signature = C/PDWwJ2NpsqbwJTVDKqosFue+rs3dl+vKPbdVqh9zIc6Lnm33/WadCA2X+tMs87UOxaeuIn+NtgL6Jnh3ZgkkWB086ltp/YbccG+H9mxCc/OXKSP2hOZdO7bE5HXi4RyoXG3Mcv/ckXlgP02v9U2gehvQCOA9mcP3XDTZvHxCvU+WQpIt/QiNW3Ov150X7HrHt9vRFlX8cY1ciLH4esDcqshLY0Cw/SinB4hUJ8eX5DanQ/5VMZY12SLMQL+y9sifrmJNIe9WP0Gysp8yGPCwcO+zP49TrEs/zmMvkUscf3+0tJTFYetF4a4+zhI7QoaV/4FWPVaBVoh7kkb0HolQ==, sign_algorithm = SHA512withRSA
```

### Verify
This function verify message with KMS key

```python
from src.vcc_kms_client.auth.kms_credentials import KMSCredentials
from src.vcc_kms_client.models import sign_algorithm
from src.vcc_kms_client.models.verify_request import VerifyRequest
from src.vcc_kms_client.kms_client import KMSClient

f = open("file/security_file.json", "r")
credentals = KMSCredentials(f)
kms = KMSClient(credentals)
request = VerifyRequest('01GZX850ZW3W4HC40T1ZX6V8NA', 'cuong dep zai', sign_algorithm.SHA512_RSA,
                        'C/PDWwJ2NpsqbwJTVDKqosFue+rs3dl+vKPbdVqh9zIc6Lnm33/WadCA2X+tMs87UOxaeuIn+NtgL6Jnh3ZgkkWB086ltp/YbccG+H9mxCc/OXKSP2hOZdO7bE5HXi4RyoXG3Mcv/ckXlgP02v9U2gehvQCOA9mcP3XDTZvHxCvU+WQpIt/QiNW3Ov150X7HrHt9vRFlX8cY1ciLH4esDcqshLY0Cw/SinB4hUJ8eX5DanQ/5VMZY12SLMQL+y9sifrmJNIe9WP0Gysp8yGPCwcO+zP49TrEs/zmMvkUscf3+0tJTFYetF4a4+zhI7QoaV/4FWPVaBVoh7kkb0HolQ==')
print(kms.verify(request))
```
Response
```text
key_id = 01GZX850ZW3W4HC40T1ZX6V8NA, signature_valid = True, sign_algorithm = SHA512withRSA
```

