sts_role_arn_credential.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package credentials
  2. // Deprecated: Use RamRoleArnCredential in this package instead.
  3. type StsRoleArnCredential struct {
  4. AccessKeyId string
  5. AccessKeySecret string
  6. RoleArn string
  7. RoleSessionName string
  8. RoleSessionExpiration int
  9. }
  10. type RamRoleArnCredential struct {
  11. AccessKeyId string
  12. AccessKeySecret string
  13. RoleArn string
  14. RoleSessionName string
  15. RoleSessionExpiration int
  16. Policy string
  17. }
  18. // Deprecated: Use RamRoleArnCredential in this package instead.
  19. func NewStsRoleArnCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName string, roleSessionExpiration int) *StsRoleArnCredential {
  20. return &StsRoleArnCredential{
  21. AccessKeyId: accessKeyId,
  22. AccessKeySecret: accessKeySecret,
  23. RoleArn: roleArn,
  24. RoleSessionName: roleSessionName,
  25. RoleSessionExpiration: roleSessionExpiration,
  26. }
  27. }
  28. func (oldCred *StsRoleArnCredential) ToRamRoleArnCredential() *RamRoleArnCredential {
  29. return &RamRoleArnCredential{
  30. AccessKeyId: oldCred.AccessKeyId,
  31. AccessKeySecret: oldCred.AccessKeySecret,
  32. RoleArn: oldCred.RoleArn,
  33. RoleSessionName: oldCred.RoleSessionName,
  34. RoleSessionExpiration: oldCred.RoleSessionExpiration,
  35. }
  36. }
  37. func NewRamRoleArnCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName string, roleSessionExpiration int) *RamRoleArnCredential {
  38. return &RamRoleArnCredential{
  39. AccessKeyId: accessKeyId,
  40. AccessKeySecret: accessKeySecret,
  41. RoleArn: roleArn,
  42. RoleSessionName: roleSessionName,
  43. RoleSessionExpiration: roleSessionExpiration,
  44. }
  45. }
  46. func NewRamRoleArnWithPolicyCredential(accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string, roleSessionExpiration int) *RamRoleArnCredential {
  47. return &RamRoleArnCredential{
  48. AccessKeyId: accessKeyId,
  49. AccessKeySecret: accessKeySecret,
  50. RoleArn: roleArn,
  51. RoleSessionName: roleSessionName,
  52. RoleSessionExpiration: roleSessionExpiration,
  53. Policy: policy,
  54. }
  55. }