github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v3/extensions/trusts/requests.go (about)

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