requests.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package trusts
  2. import "devel.mephi.ru/iacherepanov/openstack-gophercloud/openstack/identity/v3/tokens"
  3. // AuthOptsExt extends the base Identity v3 tokens AuthOpts with a TrustID.
  4. type AuthOptsExt struct {
  5. tokens.AuthOptionsBuilder
  6. // TrustID is the ID of the trust.
  7. TrustID string `json:"id"`
  8. }
  9. // ToTokenV3CreateMap builds a create request body from the AuthOpts.
  10. func (opts AuthOptsExt) ToTokenV3CreateMap(scope map[string]interface{}) (map[string]interface{}, error) {
  11. return opts.AuthOptionsBuilder.ToTokenV3CreateMap(scope)
  12. }
  13. // ToTokenV3ScopeMap builds a scope from AuthOpts.
  14. func (opts AuthOptsExt) ToTokenV3ScopeMap() (map[string]interface{}, error) {
  15. b, err := opts.AuthOptionsBuilder.ToTokenV3ScopeMap()
  16. if err != nil {
  17. return nil, err
  18. }
  19. if opts.TrustID != "" {
  20. if b == nil {
  21. b = make(map[string]interface{})
  22. }
  23. b["OS-TRUST:trust"] = map[string]interface{}{
  24. "id": opts.TrustID,
  25. }
  26. }
  27. return b, nil
  28. }
  29. func (opts AuthOptsExt) CanReauth() bool {
  30. return opts.AuthOptionsBuilder.CanReauth()
  31. }