github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/apis/results.go (about) 1 package apis 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type commonResult struct { 9 golangsdk.Result 10 } 11 12 // CreateResult represents a result of the Create method. 13 type CreateResult struct { 14 commonResult 15 } 16 17 // GetResult represents a result of the Get method. 18 type GetResult struct { 19 commonResult 20 } 21 22 // UpdateResult represents a result of the Update method. 23 type UpdateResult struct { 24 commonResult 25 } 26 27 // APIResp is a struct that represents the result of Create, Update, Get and List methods. 28 type APIResp struct { 29 // API name which can contains of 3 to 64 characters, starting with a letter. 30 // Only letters, digits, and underscores (_) are allowed. 31 // Chinese characters must be in UTF-8 or Unicode format. 32 Name string `json:"name"` 33 // API type. The valid types are as following: 34 // 1: public API 35 // 2: private API 36 Type int `json:"type"` 37 // API version which can contains maximum of 16 characters. 38 Version string `json:"version"` 39 // Request protocol. 40 // HTTP 41 // HTTPS (default) 42 // BOTH: The API can be accessed through both HTTP and HTTPS. 43 ReqProtocol string `json:"req_protocol"` 44 // Request method. The valid values are GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS and ANY. 45 ReqMethod string `json:"req_method"` 46 // Request address, which can contain request parameters enclosed with brackets ({}). For example, 47 // /getUserInfo/{userId}. 48 // The request address can contain special characters, such as asterisks (*), percent signs (%), hyphens (-), and underscores (_). It can contain a maximum of 512 characters and must comply with URI specifications. 49 // The request address must comply with URI specifications. 50 ReqURI string `json:"req_uri"` 51 // Security authentication mode. The valid values are as following: 52 // NONE 53 // APP 54 // IAM 55 // AUTHORIZER 56 AuthType string `json:"auth_type"` 57 // Security authentication parameter. 58 AuthOpt AuthOpt `json:"auth_opt"` 59 // Indicates whether CORS is supported. 60 // TRUE: supported 61 // FALSE: not supported (default). 62 Cors bool `json:"cors"` 63 // Route matching mode. 64 // SWA: prefix match 65 // NORMAL: exact match (default). 66 MatchMode string `json:"match_mode"` 67 // Backend type. The valid types are as following: 68 // HTTP: web backend 69 // FUNCTION: FunctionGraph backend 70 // MOCK: Mock backend 71 BackendType string `json:"backend_type"` 72 // Description of the API, which can contain a maximum of 255 characters. 73 // Chinese characters must be in UTF-8 or Unicode format. 74 Description string `json:"remark"` 75 // ID of the API group to which the API belongs. 76 GroupId string `json:"group_id"` 77 // API request body, which can be an example request body, media type, or parameters. 78 // Ensure that the request body does not exceed 20,480 characters. 79 // Chinese characters must be in UTF-8 or Unicode format. 80 BodyDescription string `json:"body_remark"` 81 // Example response for a successful request. Ensure that the response does not exceed 20,480 characters. 82 // Chinese characters must be in UTF-8 or Unicode format. 83 ResultNormalSample string `json:"result_normal_sample"` 84 // Example response for a failed request. Ensure that the response does not exceed 20,480 characters. 85 // Chinese characters must be in UTF-8 or Unicode format. 86 ResultFailureSample string `json:"result_failure_sample"` 87 // ID of the frontend custom authorizer. 88 AuthorizerId string `json:"authorizer_id"` 89 // Tags. 90 Tags []string `json:"tags"` 91 // Group response ID. 92 ResponseId string `json:"response_id"` 93 // API ID. 94 ID string `json:"id"` 95 // API status. 1: valid 96 Status int `json:"status"` 97 // Indicates whether to enable orchestration. 98 ArrangeNecessary int `json:"arrange_necessary"` 99 // Time when the API is registered. 100 RegisterTime string `json:"register_time"` 101 // Time when the API was last modified. 102 UpdateTime string `json:"update_time"` 103 // Name of the API group to which the API belongs. 104 GroupName string `json:"group_name"` 105 // Version of the API group to which the API belongs. 106 // The default value is V1. Other versions are not supported. 107 GroupVersion string `json:"group_version"` 108 // ID of the environment in which the API has been published. 109 // If there are multiple publication records, separate the environment IDs with vertical bars (|). 110 RunEnvId string `json:"run_env_id"` 111 // Name of the environment in which the API has been published. 112 // If there are multiple publication records, separate the environment names with vertical bars (|). 113 RunEnvName string `json:"run_env_name"` 114 // Publication record ID. 115 // You can separate multiple publication record IDs with vertical bars (|). 116 PublishId string `json:"publish_id"` 117 // FunctionGraph backend details. 118 FuncInfo FuncGraph `json:"func_info"` 119 // Mock backend details. 120 MockInfo Mock `json:"mock_info"` 121 // Web backend details. 122 WebInfo Web `json:"backend_api"` 123 // Request parameters. 124 ReqParams []ReqParamResp `json:"req_params"` 125 // Backend parameters. 126 BackendParams []BackendParamResp `json:"backend_params"` 127 // Mock policy backends. 128 PolicyMocks []PolicyMockResp `json:"policy_mocks"` 129 // FunctionGraph policy backends. 130 PolicyFunctions []PolicyFuncGraphResp `json:"policy_functions"` 131 // Web policy backends. 132 PolicyWebs []PolicyWebResp `json:"policy_https"` 133 // The following four parameters are only provided by the response of the API Versions. 134 // SlDomain 135 // SlDomains 136 // VersionId 137 // PublishTime. 138 // Subdomain name that API Gateway automatically allocates to the API group. 139 SlDomain string `json:"sl_domain"` 140 // Subdomain names that API Gateway automatically allocates to the API group. 141 SlDomains []string `json:"sl_domains"` 142 // API version ID. 143 VersionId string `json:"version_id"` 144 //Time when the API version is published. 145 PublishTime string `json:"publish_time"` 146 } 147 148 // ReqParamResp is an object struct that represents the elements of the front-end request parameter. 149 type ReqParamResp struct { 150 // The parameter name, which contain of 1 to 32 characters and start with a letter. 151 // Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed. 152 Name string `json:"name"` 153 // Parameter type. The valid types are as following: 154 // STRING 155 // NUMBER 156 Type string `json:"type"` 157 // Parameter location. The valid modes are as following: 158 // PATH 159 // QUERY 160 // HEADER 161 Location string `json:"location"` 162 // Default value. 163 DefaultValue string `json:"default_value"` 164 // Example value. 165 SampleValue string `json:"sample_value"` 166 // Indicates whether the parameter is required. The valid values are 1 (yes) and 2 (no). 167 // The value of this parameter is 1 if Location is set to PATH, and 2 if Location is set to another value. 168 Required int `json:"required"` 169 // Indicates whether validity check is enabled. The valid modes are as following: 170 // 1: enabled. 171 // 2: disabled (default). 172 ValidEnable int `json:"valid_enable"` 173 // Description about the backend, which can contain a maximum of 255 characters. 174 // Chinese characters must be in UTF-8 or Unicode format. 175 Description string `json:"remark"` 176 // Enumerated value. 177 Enumerations string `json:"enumerations"` 178 // Minimum value. 179 // This parameter is valid when type is set to NUMBER. 180 MinNum int `json:"min_num"` 181 // Maximum value. 182 // This parameter is valid when type is set to NUMBER. 183 MaxNum int `json:"max_num"` 184 // Minimum length. 185 // This parameter is valid when type is set to STRING. 186 MinSize int `json:"min_size"` 187 // Maximum length. 188 // This parameter is valid when type is set to STRING. 189 MaxSize int `json:"max_size"` 190 // Indicates whether to transparently transfer the parameter. The valid values are 1 (yes) and 2 (no). 191 PassThrough int `json:"pass_through"` 192 // Parameter ID. 193 // Notes: This parameter is used for response. 194 ID string `json:"id"` 195 } 196 197 // BackendParamResp is an object struct that represents the elements of the back-end parameter. 198 type BackendParamResp struct { 199 // Parameter type. The valid types are as following: 200 // REQUEST: Backend parameter. 201 // CONSTANT: Constant parameter. 202 // SYSTEM: System parameter. 203 Origin string `json:"origin"` 204 // Parameter name, which can contains 1 to 32 characters, must start with a letter and can only contain letters, digits, hyphens (-), underscores (_), 205 // and periods (.). 206 Name string `json:"name"` 207 // Description, which can contain a maximum of 255 characters. 208 // Chinese characters must be in UTF-8 or Unicode format. 209 Description string `json:"remark"` 210 // Parameter location. The valid values are PATH, QUERY and HEADER. 211 Location string `json:"location"` 212 // Parameter value, which can contain a maximum of 255 characters. 213 // If the origin type is REQUEST, the value of this parameter is the parameter name in req_params. 214 // If the origin type is CONSTANT, the value is a constant. 215 // If the origin type is SYSTEM, the value is a system parameter name. 216 // System parameters include gateway parameters, front-end authentication parameters, and back-end authentication 217 // parameters. You can set the frontend or backend authentication parameters after enabling custom frontend or 218 // backend authentication. 219 // The gateway parameters are as follows: 220 // $context.sourceIp: source IP address of the API caller. 221 // $context.stage: deployment environment in which the API is called. 222 // $context.apiId: API ID. 223 // $context.appId: ID of the app used by the API caller. 224 // $context.requestId: request ID generated when the API is called. 225 // $context.serverAddr: address of the gateway server. 226 // $context.serverName: name of the gateway server. 227 // $context.handleTime: time when the API request is processed. 228 // $context.providerAppId: ID of the app used by the API owner. This parameter is currently not supported. 229 // Frontend authentication parameter: prefixed with "$context.authorizer.frontend.". 230 // For example, to return "aaa" upon successful custom authentication, set this parameter to 231 // "$context.authorizer.frontend.aaa". 232 // Backend authentication parameter: prefixed with "$context.authorizer.backend.". 233 // For example, to return "aaa" upon successful custom authentication, set this parameter to 234 // "$context.authorizer.backend.aaa". 235 Value string `json:"value"` 236 // ID of the the specifies request parameter. 237 ReqParamId string `json:"req_param_id"` 238 } 239 240 // PolicyMockResp is an object struct that represents the back-end policy of mock. 241 type PolicyMockResp struct { 242 // Policy conditions. 243 Conditions []APIConditionBase `json:"conditions" required:"true"` 244 // Effective mode of the backend policy. The valid modes are as following: 245 // ALL: All conditions are met. 246 // ANY: Any condition is met. 247 EffectMode string `json:"effect_mode" required:"true"` 248 // Backend name, which consists of 3 to 64 characters and must start with a letter and can contain letters, digits, 249 // and underscores (_). 250 Name string `json:"name" required:"true"` 251 // Authorizer ID. 252 AuthorizerId string `json:"authorizer_id,omitempty"` 253 // Backend parameters. 254 BackendParams []BackendParamResp `json:"backend_params,omitempty"` 255 // Response. 256 ResultContent string `json:"result_content,omitempty"` 257 } 258 259 // PolicyFuncGraphResp is an object struct that represents the back-end policy of function graph. 260 type PolicyFuncGraphResp struct { 261 // Policy conditions. 262 Conditions []APIConditionBase `json:"conditions" required:"true"` 263 // Effective mode of the backend policy. 264 // ALL: All conditions are met. 265 // ANY: Any condition is met. 266 EffectMode string `json:"effect_mode" required:"true"` 267 // Function URN. 268 FunctionUrn string `json:"function_urn" required:"true"` 269 // Invocation mode. The valid modes are as following: 270 // async: asynchronous 271 // sync: synchronous 272 InvocationType string `json:"invocation_type" required:"true"` 273 // The backend name, which can consists of 3 to 64 characters and must start with a letter and can contain letters, 274 // digits, and underscores (_). 275 Name string `json:"name" required:"true"` 276 // Authorizer ID. 277 AuthorizerId string `json:"authorizer_id,omitempty"` 278 // Backend parameters. 279 BackendParams []BackendParamResp `json:"backend_params,omitempty"` 280 // Timeout, in ms, which allowed for API Gateway to request the backend service. 281 // The valid value is range from 1 to 600,000. 282 Timeout int `json:"timeout,omitempty"` 283 // Function version Ensure that the version does not exceed 64 characters. 284 Version string `json:"version,omitempty"` 285 } 286 287 // PolicyWebResp is an object struct that represents the back-end policy of http and https. 288 type PolicyWebResp struct { 289 // Request protocol. The value can be HTTP or HTTPS. 290 ReqProtocol string `json:"req_protocol" required:"true"` 291 // Request method. The valid methods are GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS and ANY. 292 ReqMethod string `json:"req_method" required:"true"` 293 // Request address, which can contain request parameters enclosed with brackets ({}). For example, 294 // /getUserInfo/{userId}. 295 // The request address can contain special characters, such as asterisks (), percent signs (%), hyphens (-), and 296 // underscores (_). It can contain a maximum of 512 characters and must comply with URI specifications. 297 // The request address can contain environment variables, each starting with a letter and consisting of 3 to 32 298 // characters. Only letters, digits, hyphens (-), and underscores (_) are allowed in environment variables. 299 // The request address must comply with URI specifications. 300 ReqURI string `json:"req_uri" required:"true"` 301 // Endpoint of the policy backend. 302 // An endpoint consists of a domain name or IP address and a port number, with not more than 255 characters. 303 // It must be in the format "Domain name:Port number", for example, apig.example.com:7443. 304 // If the port number is not specified, the default HTTPS port 443 or the default HTTP port 80 is used. 305 // The endpoint can contain environment variables, each starting with letter and consisting of 3 to 32 characters. 306 // Only letters, digits, hyphens (-), and underscores (_) are allowed. 307 DomainURL string `json:"url_domain,omitempty"` 308 // Timeout, in ms, which allowed for API Gateway to request the backend service. 309 // The valid value is range from 1 to 600,000. 310 Timeout int `json:"timeout,omitempty"` 311 // Effective mode of the backend policy. The valid modes are as following: 312 // ALL: All conditions are met. 313 // ANY: Any condition is met. 314 EffectMode string `json:"effect_mode" required:"true"` 315 // Backend name, which contains of 3 to 64 and must start with a letter and can contain letters, digits, and 316 // underscores (_). 317 Name string `json:"name" required:"true"` 318 // Backend parameters. 319 BackendParams []BackendParamResp `json:"backend_params,omitempty"` 320 // Policy conditions. 321 Conditions []APIConditionBase `json:"conditions" required:"true"` 322 // Authorizer ID. 323 AuthorizerId string `json:"authorizer_id,omitempty"` 324 // VPC channel details. This parameter is required if vpc_channel_status is set to 1. 325 VpcChannelInfo VpcChannel `json:"vpc_channel_info,omitempty"` 326 // Indicates whether to use a VPC channel. The valid value are as following: 327 // 1: A VPC channel is used. 328 // 2: No VPC channel is used. 329 VpcChannelEnable int `json:"vpc_channel_status,omitempty"` 330 } 331 332 // Extract is a method to extract an response struct. 333 func (r commonResult) Extract() (*APIResp, error) { 334 var s APIResp 335 err := r.ExtractInto(&s) 336 return &s, err 337 } 338 339 // APIPage represents the api pages of the List operation. 340 type APIPage struct { 341 pagination.SinglePageBase 342 } 343 344 // ExtractApis is a method to extract an response struct list. 345 func ExtractApis(r pagination.Page) ([]APIResp, error) { 346 var s []APIResp 347 err := r.(APIPage).Result.ExtractIntoSlicePtr(&s, "apis") 348 return s, err 349 } 350 351 // DeleteResult represents a result of the Delete method. 352 type DeleteResult struct { 353 golangsdk.ErrResult 354 }