github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/workspace/v2/accesspolicies/results.go (about) 1 package accesspolicies 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 type policiesResp struct { 6 // List of policy. 7 Policies []AccessPolicyDetailInfo `json:"policies"` 8 // Total number of the policies. 9 Total int `json:"total"` 10 } 11 12 // AccessPolicyDetailInfo is the structure that represents the access policy information. 13 type AccessPolicyDetailInfo struct { 14 // Policy name. 15 // + PRIVATE_ACCESS: Private line access 16 PolicyName string `json:"policy_name"` 17 // Blacklist type. 18 // + INTERNET: Internet. 19 BlacklistType string `json:"blacklist_type"` 20 // Policy ID. 21 PolicyId string `json:"policy_id"` 22 // The creation time of the policy. 23 CreateTime string `json:"create_time"` 24 } 25 26 // AccessPolicyObject is the structure that represents the policy access object information. 27 type AccessPolicyObject struct { 28 // Object ID. 29 ObjectId string `json:"object_id"` 30 // Object name. 31 ObjectName string `json:"object_name"` 32 // Object type. 33 ObjectType string `json:"object_type"` 34 } 35 36 // AccessPolicyPage is a single page maximum result representing a query by offset page. 37 type AccessPolicyPage struct { 38 pagination.OffsetPageBase 39 } 40 41 // IsEmpty checks whether an AccessPolicyPage struct is empty. 42 func (b AccessPolicyPage) IsEmpty() (bool, error) { 43 arr, err := ExtractAccessPolicies(b) 44 return len(arr) == 0, err 45 } 46 47 // ExtractAccessPolicies is a method to extract the list of access objects. 48 func ExtractAccessPolicies(r pagination.Page) ([]AccessPolicyObject, error) { 49 var s []AccessPolicyObject 50 err := r.(AccessPolicyPage).Result.ExtractIntoSlicePtr(&s, "policy_objects_list") 51 return s, err 52 }