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

     1  package apis
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/huaweicloud/golangsdk"
     7  )
     8  
     9  type BackendInfo struct {
    10  	Protocol  string `json:"req_protocol"`
    11  	Method    string `json:"req_method"`
    12  	Uri       string `json:"req_uri"`
    13  	Timeout   int    `json:"timeout"`
    14  	VpcStatus int    `json:"vpc_status"`
    15  	VpcInfo   string `json:"vpc_info"`
    16  	UrlDomain string `json:"url_domain"`
    17  	Version   string `json:"version"`
    18  	Remark    string `json:"remark"`
    19  }
    20  
    21  type FunctionInfo struct {
    22  	FunctionUrn    string `json:"function_urn" required:"true"`
    23  	InvocationType string `json:"invocation_type" required:"true"`
    24  	Timeout        int    `json:"timeout" required:"true"`
    25  	Version        string `json:"version,omitempty"`
    26  	Remark         string `json:"remark,omitempty"`
    27  }
    28  
    29  type MockInfo struct {
    30  	ResultContent string `json:"result_content,omitempty"`
    31  	Version       string `json:"version,omitempty"`
    32  	Remark        string `json:"remark,omitempty"`
    33  }
    34  
    35  type BackendParameter struct {
    36  	Name     string `json:"name" required:"true"`
    37  	Location string `json:"location" required:"true"`
    38  	Origin   string `json:"origin" required:"true"`
    39  	Value    string `json:"value" required:"true"`
    40  	Remark   string `json:"remark,omitempty"`
    41  }
    42  
    43  type RequestParameter struct {
    44  	Name         string `json:"name" required:"true"`
    45  	Type         string `json:"type" required:"true"`
    46  	Location     string `json:"location" required:"true"`
    47  	Required     int    `json:"required" required:"true"`
    48  	ValidEnable  int    `json:"valid_enable" required:"true"`
    49  	DefaultValue string `json:"default_value,omitempty"`
    50  	SampleValue  string `json:"sample_value,omitempty"`
    51  	Remark       string `json:"remark,omitempty"`
    52  	Enumerations string `json:"enumerations,omitempty"`
    53  	MinNum       int    `json:"min_num,omitempty"`
    54  	MaxNum       int    `json:"max_num,omitempty"`
    55  	MinSize      int    `json:"min_size,omitempty"`
    56  	MaxSize      int    `json:"max_size,omitempty"`
    57  }
    58  
    59  // ApiInstance contains all the information associated with a API.
    60  type ApiInstance struct {
    61  	// ID of the API
    62  	Id string `json:"id"`
    63  	// Name of the API
    64  	Name string `json:"name"`
    65  	// ID of the API group to which the API to be created will belong
    66  	GroupId string `json:"group_id"`
    67  	// Name of the API group
    68  	GroupName string `json:"group_name"`
    69  	// status of the API
    70  	Status int `json:"status"`
    71  	// Type of the API. 1: public, 2: private
    72  	Type int `json:"type"`
    73  	// Version of the API
    74  	Version string `json:"version"`
    75  	// Request protocol
    76  	ReqProtocol string `json:"req_protocol"`
    77  	// Request method
    78  	ReqMethod string `json:"req_method"`
    79  	// Access address
    80  	ReqUri string `json:"req_uri"`
    81  	// Request parameter list
    82  	ReqParams []RequestParameter `json:"req_params"`
    83  	// Security authentication mode, which can be: None, App and IAM
    84  	AuthType string `json:"auth_type"`
    85  	// Route matching mode
    86  	MatchMode string `json:"match_mode"`
    87  	// backend type, which can be: HTTP, Function and MOCK
    88  	BackendType string `json:"backend_type"`
    89  	// Backend parameter list
    90  	BackendParams []BackendParameter `json:"backend_params"`
    91  	//Web backend details
    92  	BackendInfo BackendInfo `json:"backend_api"`
    93  	// FunctionGraph backend details
    94  	FunctionInfo FunctionInfo `json:"func_info"`
    95  	// Mock backend details
    96  	MockInfo MockInfo `json:"mock_info"`
    97  	// Example response for a successful request
    98  	ResultNormalSample string `json:"result_normal_sample"`
    99  	// Example response for a failed request
   100  	ResultFailureSample string `json:"result_failure_sample"`
   101  	// Description of the API
   102  	Remark string `json:"remark"`
   103  	// tags of the API
   104  	Tags []string `json:"tags"`
   105  	// Description of the API request body
   106  	BodyRemark string `json:"body_remark"`
   107  	// whether CORS is supported
   108  	Cors bool `json:"cors"`
   109  
   110  	EnvName          string    `json:"run_env_name"`
   111  	EnvId            string    `json:"run_env_id"`
   112  	PublishId        string    `json:"publish_id"`
   113  	ArrangeNecessary int       `json:"arrange_necessary"`
   114  	RegisterAt       time.Time `json:"-"`
   115  	UpdateAt         time.Time `json:"-"`
   116  }
   117  
   118  type commonResult struct {
   119  	golangsdk.Result
   120  }
   121  
   122  // Extract will get the Group object out of the commonResult object.
   123  func (r commonResult) Extract() (*ApiInstance, error) {
   124  	var s ApiInstance
   125  	err := r.ExtractInto(&s)
   126  	return &s, err
   127  }
   128  
   129  // CreateResult contains the response body and error from a Create request.
   130  type CreateResult struct {
   131  	commonResult
   132  }
   133  
   134  // GetResult contains the response body and error from a Get request.
   135  type GetResult struct {
   136  	commonResult
   137  }
   138  
   139  // UpdateResult contains the response body and error from an Update request.
   140  type UpdateResult struct {
   141  	commonResult
   142  }
   143  
   144  // DeleteResult contains the response body and error from a Delete request.
   145  type DeleteResult struct {
   146  	golangsdk.ErrResult
   147  }