github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/responses/results.go (about)

     1  package responses
     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 operation.
    18  type GetResult struct {
    19  	commonResult
    20  }
    21  
    22  // UpdateResult represents a result of the Update operation.
    23  type UpdateResult struct {
    24  	commonResult
    25  }
    26  
    27  type Response struct {
    28  	// Response ID.
    29  	Id string `json:"id"`
    30  	// Response name.
    31  	Name string `json:"name"`
    32  	// Response type definition, which includes a key and value. Options of the key:
    33  	//     AUTH_FAILURE: Authentication failed.
    34  	//     AUTH_HEADER_MISSING: The identity source is missing.
    35  	//     AUTHORIZER_FAILURE: Custom authentication failed.
    36  	//     AUTHORIZER_CONF_FAILURE: There has been a custom authorizer error.
    37  	//     AUTHORIZER_IDENTITIES_FAILURE: The identity source of the custom authorizer is invalid.
    38  	//     BACKEND_UNAVAILABLE: The backend service is unavailable.
    39  	//     BACKEND_TIMEOUT: Communication with the backend service timed out.
    40  	//     THROTTLED: The request was rejected due to request throttling.
    41  	//     UNAUTHORIZED: The app you are using has not been authorized to call the API.
    42  	//     ACCESS_DENIED: Access denied.
    43  	//     NOT_FOUND: No API is found.
    44  	//     REQUEST_PARAMETERS_FAILURE: The request parameters are incorrect.
    45  	//     DEFAULT_4XX: Another 4XX error occurred.
    46  	//     DEFAULT_5XX: Another 5XX error occurred.
    47  	// Each error type is in JSON format.
    48  	Responses map[string]ResponseInfo `json:"responses"`
    49  	// Indicates whether the group response is the default response.
    50  	IsDefault bool `json:"default"`
    51  	// Creation time.
    52  	CreateTime string `json:"create_time"`
    53  	// Update time.
    54  	UpdateTime string `json:"update_time"`
    55  }
    56  
    57  // Extract is a method to extract an response struct.
    58  func (r commonResult) Extract() (*Response, error) {
    59  	var s Response
    60  	err := r.ExtractInto(&s)
    61  	return &s, err
    62  }
    63  
    64  // ResponsePage represents the response pages of the List operation.
    65  type ResponsePage struct {
    66  	pagination.SinglePageBase
    67  }
    68  
    69  // ExtractResponses is a method to extract an response struct list.
    70  func ExtractResponses(r pagination.Page) ([]Response, error) {
    71  	var s []Response
    72  	err := r.(ResponsePage).Result.ExtractIntoSlicePtr(&s, "responses")
    73  	return s, err
    74  }
    75  
    76  // DeleteResult represents a result of the Delete and DeleteSpecResp method.
    77  type DeleteResult struct {
    78  	golangsdk.ErrResult
    79  }
    80  
    81  type SpecRespResult struct {
    82  	commonResult
    83  }
    84  
    85  // GetSpecRespResult represents a result of the GetSpecResp method.
    86  type GetSpecRespResult struct {
    87  	SpecRespResult
    88  }
    89  
    90  // UpdateSpecRespResult represents a result of the UpdateSpecResp method.
    91  type UpdateSpecRespResult struct {
    92  	SpecRespResult
    93  }
    94  
    95  // ExtractSpecResp is a method to extract an response struct using a specifies key.
    96  func (r SpecRespResult) ExtractSpecResp(key string) (*ResponseInfo, error) {
    97  	var s ResponseInfo
    98  	err := r.ExtractIntoStructPtr(&s, key)
    99  	return &s, err
   100  }