github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/apigw/dedicated/v2/plugins/results.go (about)

     1  package plugins
     2  
     3  import "github.com/chnsz/golangsdk/pagination"
     4  
     5  // Plugin is the structure that represents the plugin detail.
     6  type Plugin struct {
     7  	// The plugin ID.
     8  	ID string `json:"plugin_id"`
     9  	// Plugin name.
    10  	// The valid length is limited from `3` to `255`, only Chinese characters, English letters, digits, hyphens (-) and
    11  	// underscores (_) are allowed. The name must start with an English letter or Chinese character.
    12  	Name string `json:"plugin_name"`
    13  	// Plugin type.
    14  	// The valid values are as follows:
    15  	// + 'cors': CORS, specify preflight request headers and response headers and automatically create preflight
    16  	//   request APIs for cross-origin API access.
    17  	// + 'set_resp_headers': HTTP Response Header Management, customize HTTP headers that will be contained in an API
    18  	//   response.
    19  	// + 'rate_limit': Request Throttling 2.0, limits the number of times an API can be called within a specific time
    20  	//   period. It supports parameter-based, basic, and excluded throttling.
    21  	// + 'kafka_log': Kafka Log Push, Push detailed API calling logs to kafka for you to easily obtain logs.
    22  	// + 'breaker': Circuit Breaker, circuit breaker protect the system when performance issues occur on backend
    23  	//   service.
    24  	Type string `json:"plugin_type"`
    25  	// The available scope for plugin, the valid value is 'global'.
    26  	Scope string `json:"plugin_scope"`
    27  	// The configuration details for plugin.
    28  	Content string `json:"plugin_content"`
    29  	// The plugin description.
    30  	// The valid length is limited from `3` to `255` characters.
    31  	Description string `json:"remark"`
    32  	// The creation time.
    33  	CreatedAt string `json:"created_at"`
    34  	// The latest update time.
    35  	UpdatedAt string `json:"updated_at"`
    36  }
    37  
    38  // BindResp is the structure that represents the API response of the plugin binding.
    39  type BindResp struct {
    40  	// The published APIs of the binding relationship.
    41  	Bindings []PluginBindDetail `json:"bindings"`
    42  }
    43  
    44  // PluginBindDetail is the structure that represents the binding details.
    45  type PluginBindDetail struct {
    46  	// The binding ID.
    47  	BindId string `json:"plugin_attach_id"`
    48  	// The plugin ID.
    49  	PluginId string `json:"plugin_id"`
    50  	// The plugin name.
    51  	PluginName string `json:"plugin_name"`
    52  	// Plugin type.
    53  	// The valid values are as follows:
    54  	// + 'cors': CORS, specify preflight request headers and response headers and automatically create preflight
    55  	//   request APIs for cross-origin API access.
    56  	// + 'set_resp_headers': HTTP Response Header Management, customize HTTP headers that will be contained in an API
    57  	//   response.
    58  	// + 'rate_limit': Request Throttling 2.0, limits the number of times an API can be called within a specific time
    59  	//   period. It supports parameter-based, basic, and excluded throttling.
    60  	// + 'kafka_log': Kafka Log Push, Push detailed API calling logs to kafka for you to easily obtain logs.
    61  	// + 'breaker': Circuit Breaker, circuit breaker protect the system when performance issues occur on backend
    62  	//   service.
    63  	PluginType string `json:"plugin_type"`
    64  	// The available scope for plugin, the valid value is 'global'.
    65  	PluginScope string `json:"plugin_scope"`
    66  	// The environment ID where the API is published.
    67  	EnvId string `json:"env_id"`
    68  	// The name of the environment published by the API.
    69  	EnvName string `json:"env_name"`
    70  	// The API ID.
    71  	ApiId string `json:"api_id"`
    72  	// The API name.
    73  	ApiName string `json:"apig_name"`
    74  	// The time when the API and the plugin were bound.
    75  	BoundAt string `json:"attached_time"`
    76  }
    77  
    78  // BindPage is a single page maximum result representing a query by offset page.
    79  type BindPage struct {
    80  	pagination.OffsetPageBase
    81  }
    82  
    83  // IsEmpty checks whether a BindPage struct is empty.
    84  func (b BindPage) IsEmpty() (bool, error) {
    85  	arr, err := ExtractBindInfos(b)
    86  	return len(arr) == 0, err
    87  }
    88  
    89  // ExtractBindInfos is a method to extract the list of binding details for plugin.
    90  func ExtractBindInfos(r pagination.Page) ([]BindApiInfo, error) {
    91  	var s []BindApiInfo
    92  	err := r.(BindPage).Result.ExtractIntoSlicePtr(&s, "apis")
    93  	return s, err
    94  }
    95  
    96  // BindApiInfo is an object that represents the bind detail.
    97  type BindApiInfo struct {
    98  	// API ID.
    99  	ApiId string `json:"api_id"`
   100  	// API name.
   101  	ApiName string `json:"api_name"`
   102  	// API type.
   103  	Type int `json:"type"`
   104  	// The request protocol of the API.
   105  	RequestProtocol string `json:"req_protocol"`
   106  	// The request method of the API.
   107  	RequestMethod string `json:"req_method"`
   108  	// The request URI of the API.
   109  	RequestUri string `json:"request_uri"`
   110  	// The authorization type of the API.
   111  	AuthType string `json:"auth_type"`
   112  	// The match mode of the API.
   113  	MatchMode string `json:"match_mode"`
   114  	// The description of the API.
   115  	Remark string `json:"remark"`
   116  	// The ID of API group to which the API belongs.
   117  	GroupId string `json:"group_id"`
   118  	// The name of API group to which the API belongs.
   119  	GroupName string `json:"group_name"`
   120  	// Home integration application code, which is compatible with the field of the Roma instance.
   121  	// Generally, the value is null.
   122  	RomaAppId string `json:"roma_app_id"`
   123  	// The ID of environment where the API was published.
   124  	EnvId string `json:"env_id"`
   125  	// The name of environment where the API was published.
   126  	EnvName string `json:"env_name"`
   127  	// The API publish ID.
   128  	PublishId string `json:"publish_id"`
   129  	// The ID of plugin policy binding.
   130  	BindId string `json:"plugin_attach_id"`
   131  	// The bound time.
   132  	BoundAt string `json:"attached_time"`
   133  }