github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/identity/v3/credentials/results.go (about)

     1  package credentials
     2  
     3  import "github.com/opentelekomcloud/gophertelekomcloud"
     4  
     5  type Credential struct {
     6  	// IAM user ID
     7  	UserID string `json:"user_id"`
     8  
     9  	// Description of the access key
    10  	Description string `json:"description"`
    11  
    12  	// Time when the access key was created
    13  	CreateTime string `json:"create_time"`
    14  
    15  	// Time when the access key was last used
    16  	LastUseTime string `json:"last_use_time,omitempty"`
    17  
    18  	// AK
    19  	AccessKey string `json:"access"`
    20  
    21  	// SK, returned only during creation
    22  	SecretKey string `json:"secret,omitempty"`
    23  
    24  	// Status of the access key, active/inactive
    25  	Status Status `json:"status"`
    26  }
    27  
    28  type credentialResult struct {
    29  	golangsdk.Result
    30  }
    31  
    32  // CreateResult is the response of a Get operations. Call its Extract method to
    33  // interpret it as a Credential.
    34  type CreateResult struct {
    35  	credentialResult
    36  }
    37  
    38  // Extract provides access to the individual Flavor returned by the Get and
    39  // Create functions.
    40  func (r credentialResult) Extract() (*Credential, error) {
    41  	var s struct {
    42  		Credential *Credential `json:"credential"`
    43  	}
    44  	err := r.ExtractInto(&s)
    45  	return s.Credential, err
    46  }
    47  
    48  // GetResult is the response of a Get operations. Call its Extract method to
    49  // interpret it as a Credential.
    50  type GetResult struct {
    51  	credentialResult
    52  }
    53  
    54  // UpdateResult is the response from an Update operation. Call its Extract
    55  // method to interpret it as a Role.
    56  type UpdateResult struct {
    57  	credentialResult
    58  }
    59  
    60  type ListResult struct {
    61  	golangsdk.Result
    62  }
    63  
    64  func (lr ListResult) Extract() ([]Credential, error) {
    65  	var a struct {
    66  		Instances []Credential `json:"credentials"`
    67  	}
    68  	err := lr.Result.ExtractInto(&a)
    69  	return a.Instances, err
    70  }
    71  
    72  // DeleteResult is the response from a Delete operation. Call its ExtractErr to
    73  // determine if the request succeeded or failed.
    74  type DeleteResult struct {
    75  	golangsdk.ErrResult
    76  }
    77  
    78  type TemporaryCredential struct {
    79  	// Expiration time
    80  	ExpiresAt string `json:"expires_at"`
    81  
    82  	// AK
    83  	AccessKey string `json:"access"`
    84  
    85  	// SK, returned only during creation
    86  	SecretKey string `json:"secret"`
    87  
    88  	// Used for subsequent replacement of an SK or token.
    89  	SecurityToken string `json:"securitytoken"`
    90  }
    91  
    92  type CreateTemporaryResult struct {
    93  	golangsdk.Result
    94  }
    95  
    96  func (r CreateTemporaryResult) Extract() (*TemporaryCredential, error) {
    97  	var s struct {
    98  		Credential *TemporaryCredential `json:"credential"`
    99  	}
   100  	err := r.ExtractInto(&s)
   101  	return s.Credential, err
   102  }