|
| 1 | +package provider |
| 2 | + |
| 3 | +import ( |
| 4 | + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" |
| 5 | + "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" |
| 6 | +) |
| 7 | + |
| 8 | +// ListOpts is the structure that used to query tags detail for specified resource. |
| 9 | +type ListOpts struct { |
| 10 | + // Specifies the display language. |
| 11 | + Locale string `q:"locale"` |
| 12 | + // The maximum queries supported. The value 10 is used by default if this parameter is not set. |
| 13 | + // The value range is 1 to 200. |
| 14 | + Limit *int `q:"limit"` |
| 15 | + // Specifies the index position, which starts from the next data record specified by offset. |
| 16 | + // The value must be a number and cannot be negative. The default value is 0. |
| 17 | + Offset *int `q:"offset"` |
| 18 | + // Specifies the cloud service name. |
| 19 | + Provider *int `q:"provider"` |
| 20 | +} |
| 21 | + |
| 22 | +func List(client *golangsdk.ServiceClient, opts ListOpts) ([]Providers, error) { |
| 23 | + url, err := golangsdk.NewURLBuilder(). |
| 24 | + WithEndpoints("tms", "providers"). |
| 25 | + WithQueryParams(&opts).Build() |
| 26 | + if err != nil { |
| 27 | + return nil, err |
| 28 | + } |
| 29 | + |
| 30 | + // GET /v1.0/tms/providers |
| 31 | + raw, err := client.Get(client.ServiceURL(url.String()), nil, &golangsdk.RequestOpts{ |
| 32 | + OkCodes: []int{200}, |
| 33 | + }) |
| 34 | + if err != nil { |
| 35 | + return nil, err |
| 36 | + } |
| 37 | + |
| 38 | + var res []Providers |
| 39 | + err = extract.IntoSlicePtr(raw.Body, &res, "providers") |
| 40 | + return res, err |
| 41 | +} |
| 42 | + |
| 43 | +type Providers struct { |
| 44 | + // Specifies the cloud service name. |
| 45 | + Provider string `json:"provider"` |
| 46 | + // Specifies the display name of the resource. |
| 47 | + // You can set the language by setting the **locale** parameter. |
| 48 | + DisplayName string `json:"provider_i18n_display_name"` |
| 49 | + // Specifies the resource type. |
| 50 | + ResourceTypes []ResourceTypes `json:"resource_types"` |
| 51 | +} |
| 52 | + |
| 53 | +type ResourceTypes struct { |
| 54 | + // Specifies the resource type. |
| 55 | + ResourceType string `json:"resource_type"` |
| 56 | + // Specifies the display name of the resource type. |
| 57 | + // You can set the language by setting the **locale** parameter. |
| 58 | + DisplayName string `json:"provider_i18n_display_name"` |
| 59 | + // Specifies the supported regions. |
| 60 | + Regions []string `json:"regions"` |
| 61 | + // Specifies whether the resource is a global resource. |
| 62 | + Global bool `json:"global"` |
| 63 | +} |
0 commit comments