github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/apigw/dedicated/v2/acls/results.go (about) 1 package acls 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 // Policy is the structure represents the ACL policy details. 6 type Policy struct { 7 // The ACL name. 8 Name string `json:"acl_name"` 9 // The ACL type. The valid values are as follows: 10 // + PERMIT 11 // + DENY 12 Type string `json:"acl_type"` 13 // The value of the ACL policy. 14 Value string `json:"acl_value"` 15 // The entity type. The valid values are as follows: 16 // + IP 17 // + DOMAIN 18 // + DOMAIN_ID 19 EntityType string `json:"entity_type"` 20 // The ID of the ACL policy. 21 ID string `json:"id"` 22 // The latest update time. 23 UpdatedAt string `json:"update_time"` 24 } 25 26 // BindPage is a single page maximum result representing a query by offset page. 27 type PolicyPage struct { 28 pagination.OffsetPageBase 29 } 30 31 // IsEmpty checks whether a PolicyPage struct is empty. 32 func (b PolicyPage) IsEmpty() (bool, error) { 33 arr, err := ExtractPolicies(b) 34 return len(arr) == 0, err 35 } 36 37 // ExtractPolicies is a method to extract the list of ACL policies. 38 func ExtractPolicies(r pagination.Page) ([]Policy, error) { 39 var s []Policy 40 err := r.(PolicyPage).Result.ExtractIntoSlicePtr(&s, "acls") 41 return s, err 42 } 43 44 // BindResp is the structure that represents the API response of the ACL policy binding. 45 type BindResp struct { 46 // The ID of the binding relationship. 47 ID string `json:"id"` 48 // The API ID. 49 ApiId string `json:"api_id"` 50 // The environment ID where the API is published. 51 EnvId string `json:"env_id"` 52 // Throttling policy ID 53 PolicyId string `json:"acl_id"` 54 // The creation time. 55 CreatedAt string `json:"create_time"` 56 } 57 58 // BindPage is a single page maximum result representing a query by offset page. 59 type BindPage struct { 60 pagination.OffsetPageBase 61 } 62 63 // IsEmpty checks whether a BindPage struct is empty. 64 func (b BindPage) IsEmpty() (bool, error) { 65 arr, err := ExtractBindInfos(b) 66 return len(arr) == 0, err 67 } 68 69 // ExtractBinds is a method to extract the list of binding details for ACL policy. 70 func ExtractBindInfos(r pagination.Page) ([]AclBindApiInfo, error) { 71 var s []AclBindApiInfo 72 err := r.(BindPage).Result.ExtractIntoSlicePtr(&s, "apis") 73 return s, err 74 } 75 76 // AclBindApiInfo is the structure that represents the binding details. 77 type AclBindApiInfo struct { 78 // The API ID. 79 ID string `json:"api_id"` 80 // The API Name. 81 Name string `json:"api_name"` 82 // The API type. 83 Type int `json:"api_type"` 84 // The API type. 85 Description string `json:"api_remark"` 86 // The environment ID where the API is published. 87 EnvId string `json:"env_id"` 88 // The name of the environment published by the API. 89 EnvName string `json:"env_name"` 90 // The binding ID. 91 BindId string `json:"bind_id"` 92 // Group name to which the API belongs. 93 GroupName string `json:"group_name"` 94 // The time when the API and the policy were bound. 95 BoundAt string `json:"bind_time"` 96 // API publish record ID. 97 PublishId string `json:"publish_id"` 98 } 99 100 // BatchUnbindResp is the structure that represents the API response of the ACL policy unbinding. 101 type BatchUnbindResp struct { 102 // Number of API and throttling policy bindings that have been successfully unbound. 103 SuccessCount int `json:"success_count"` 104 // Unbind failed error code 105 Failures []Failure `json:"failure"` 106 } 107 108 // Failure is the structure that represents the failure details. 109 type Failure struct { 110 // API and ACL policy binding relationship ID that failed to unbind. 111 BindId string `json:"bind_id"` 112 // Unbind failed error code. 113 ErrorCode string `json:"error_code"` 114 // Unbind failed error message. 115 ErrorMsg string `json:"error_msg"` 116 // ID of the API that failed to unbind. 117 ApiId string `json:"api_id"` 118 // The name of the API that failed to unbind. 119 ApiName string `json:"api_name"` 120 }