github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/kms/v1/keys/results.go (about)

     1  package keys
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/pagination"
     6  )
     7  
     8  type commonResult struct {
     9  	golangsdk.Result
    10  }
    11  
    12  // Key contains all the information associated with a CMK.
    13  type Key struct {
    14  	// Current ID of a CMK
    15  	KeyID string `json:"key_id"`
    16  	// ID of a user domain for the key.
    17  	DomainID string `json:"domain_id"`
    18  	// Alias of a CMK
    19  	KeyAlias string `json:"key_alias"`
    20  	// Key algorithm
    21  	KeySpec string `json:"key_spec"`
    22  	// Region where a CMK resides
    23  	Realm string `json:"realm"`
    24  	// Description of a CMK
    25  	KeyDescription string `json:"key_description"`
    26  	// Creation time (time stamp) of a CMK
    27  	CreationDate string `json:"creation_date"`
    28  	// Scheduled deletion time (time stamp) of a CMK
    29  	ScheduledDeletionDate string `json:"scheduled_deletion_date"`
    30  	// State of a CMK
    31  	KeyState string `json:"key_state"`
    32  	// Identification of a Master Key. The value 1 indicates a Default
    33  	// Master Key, and the value 0 indicates a CMK
    34  	DefaultKeyFlag string `json:"default_key_flag"`
    35  	// Expiration time
    36  	ExpirationTime string `json:"expiration_time"`
    37  	// Origin of a CMK. The default value is kms. The following values
    38  	// are enumerated: kms indicates that the CMK material is generated by KMS.
    39  	Origin string `json:"origin"`
    40  	//Enterprise peoject id
    41  	EnterpriseProjectID string `json:"sys_enterprise_project_id"`
    42  	// Key usage
    43  	KeyUsage string `json:"key_usage"`
    44  	// Keystore ID
    45  	KeyStoreID string `json:"keystore_id"`
    46  }
    47  
    48  type ListKey struct {
    49  	Keys       []string `json:"keys"`
    50  	KeyDetails []Key    `json:"key_details"`
    51  	NextMarker string   `json:"next_marker"`
    52  	Truncated  string   `json:"truncated"`
    53  }
    54  
    55  type DataKey struct {
    56  	// Current ID of a CMK
    57  	KeyID      string `json:"key_id"`
    58  	PlainText  string `json:"plain_text"`
    59  	CipherText string `json:"cipher_text"`
    60  }
    61  
    62  type EncryptDEK struct {
    63  	// Current ID of a CMK
    64  	KeyID         string `json:"key_id"`
    65  	DataKeyLength string `json:"datakey_length"`
    66  	CipherText    string `json:"cipher_text"`
    67  }
    68  
    69  type UpdateKeyState struct {
    70  	// Current ID of a CMK
    71  	KeyID    string `json:"key_id"`
    72  	KeyState string `json:"key_state"`
    73  }
    74  
    75  // CreateResult contains the response body and error from a Create request.
    76  type CreateResult struct {
    77  	commonResult
    78  }
    79  
    80  // GetResult contains the response body and error from a Get request.
    81  type GetResult struct {
    82  	commonResult
    83  }
    84  
    85  type ImportKeyMaterialResult struct {
    86  	commonResult
    87  }
    88  
    89  // DeleteResult contains the response body and error from a Delete request.
    90  type DeleteResult struct {
    91  	commonResult
    92  }
    93  
    94  // DeleteKeyMaterialResult contains the response body and error from a DeleteKeyMaterial request.
    95  type DeleteKeyMaterialResult struct {
    96  	commonResult
    97  }
    98  
    99  // UpdateAliasResult contains the response body and error from a UpdateAlias request.
   100  type UpdateAliasResult struct {
   101  	commonResult
   102  }
   103  
   104  // UpdateDesResult contains the response body and error from a UpdateDes request.
   105  type UpdateDesResult struct {
   106  	commonResult
   107  }
   108  
   109  type DataEncryptResult struct {
   110  	commonResult
   111  }
   112  
   113  type EncryptDEKResult struct {
   114  	commonResult
   115  }
   116  
   117  type ExtractUpdateKeyStateResult struct {
   118  	commonResult
   119  }
   120  
   121  type ListResult struct {
   122  	commonResult
   123  }
   124  
   125  func (r commonResult) ExtractListKey() (*ListKey, error) {
   126  	var s *ListKey
   127  	err := r.ExtractInto(&s)
   128  	return s, err
   129  }
   130  
   131  func (r commonResult) Extract() (*Key, error) {
   132  	var s *Key
   133  	err := r.ExtractInto(&s)
   134  	return s, err
   135  }
   136  
   137  func (r commonResult) ExtractKeyInfo() (*Key, error) {
   138  	var s Key
   139  	err := r.ExtractKeyInfoInto(&s)
   140  	return &s, err
   141  }
   142  
   143  func (r commonResult) ExtractKeyInfoInto(v interface{}) error {
   144  	return r.Result.ExtractIntoStructPtr(v, "key_info")
   145  }
   146  
   147  func (r commonResult) ExtractDataKey() (*DataKey, error) {
   148  	var s *DataKey
   149  	err := r.ExtractInto(&s)
   150  	return s, err
   151  }
   152  
   153  func (r commonResult) ExtractEncryptDEK() (*EncryptDEK, error) {
   154  	var s *EncryptDEK
   155  	err := r.ExtractInto(&s)
   156  	return s, err
   157  }
   158  
   159  type KeyPage struct {
   160  	pagination.LinkedPageBase
   161  }
   162  
   163  func (r KeyPage) IsEmpty() (bool, error) {
   164  	s, err := ExtractKeys(r)
   165  	return len(s) == 0, err
   166  }
   167  
   168  func ExtractKeys(r pagination.Page) ([]Key, error) {
   169  	var s struct {
   170  		Keys []Key `json:"keys"`
   171  	}
   172  	err := (r.(KeyPage)).ExtractInto(&s)
   173  	return s.Keys, err
   174  }