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

     1  package policies
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/pagination"
     6  )
     7  
     8  type commonResult struct {
     9  	golangsdk.Result
    10  }
    11  
    12  type ListResult struct {
    13  	commonResult
    14  }
    15  
    16  type GetResult struct {
    17  	commonResult
    18  }
    19  
    20  type CreateResult struct {
    21  	commonResult
    22  }
    23  
    24  type UpdateResult struct {
    25  	commonResult
    26  }
    27  
    28  type DeleteResult struct {
    29  	golangsdk.ErrResult
    30  }
    31  
    32  type ListPolicy struct {
    33  	Links       Links    `json:"links"`
    34  	Roles       []Policy `json:"roles"`
    35  	TotalNumber int      `json:"total_number"`
    36  }
    37  
    38  type Links struct {
    39  	Self     string `json:"self"`
    40  	Previous string `json:"previous"`
    41  	Next     string `json:"next"`
    42  }
    43  
    44  type Policy struct {
    45  	DomainId    string       `json:"domain_id"`
    46  	References  int          `json:"references,omitempty"`
    47  	UpdatedTime string       `json:"updated_time,omitempty"`
    48  	CreatedTime string       `json:"created_time,omitempty"`
    49  	Catalog     string       `json:"catalog"`
    50  	Name        string       `json:"name"`
    51  	Description string       `json:"description"`
    52  	Links       RolesLinks   `json:"links"`
    53  	ID          string       `json:"id"`
    54  	DisplayName string       `json:"display_name"`
    55  	Type        string       `json:"type"`
    56  	Policy      CustomPolicy `json:"policy"`
    57  }
    58  
    59  type RolesLinks struct {
    60  	Self string `json:"self"`
    61  }
    62  
    63  type PolicyPage struct {
    64  	pagination.LinkedPageBase
    65  }
    66  
    67  type CustomPolicy struct {
    68  	Version   string      `json:"Version"`
    69  	Statement []Statement `json:"Statement"`
    70  }
    71  
    72  type Statement struct {
    73  	Action    []string    `json:"Action"`
    74  	Effect    string      `json:"Effect"`
    75  	Condition Condition   `json:"Condition,omitempty"`
    76  	Resource  interface{} `json:"Resource,omitempty"`
    77  }
    78  
    79  func (r commonResult) ExtractPolicies() (ListPolicy, error) {
    80  	var s ListPolicy
    81  	err := r.ExtractIntoStructPtr(&s, "")
    82  	if err != nil {
    83  		return s, err
    84  	}
    85  
    86  	return s, nil
    87  }
    88  
    89  func (r commonResult) Extract() (*Policy, error) {
    90  	var s struct {
    91  		Policy *Policy `json:"role"`
    92  	}
    93  	err := r.ExtractInto(&s)
    94  	return s.Policy, err
    95  }