From c31eac67b11123271c491fa8cfaaaa437829c0cc Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Wed, 16 Nov 2022 13:10:26 +0100 Subject: [PATCH 1/6] RMS --- .../rms/v1/relations/ShowResourceRelations.go | 64 +++++++++++ .../rms/v1/resources/ListAllResources.go | 51 +++++++++ openstack/rms/v1/resources/ListProviders.go | 75 +++++++++++++ openstack/rms/v1/resources/ListResources.go | 100 ++++++++++++++++++ .../rms/v1/resources/ShowResourceById.go | 30 ++++++ 5 files changed, 320 insertions(+) create mode 100644 openstack/rms/v1/relations/ShowResourceRelations.go create mode 100644 openstack/rms/v1/resources/ListAllResources.go create mode 100644 openstack/rms/v1/resources/ListProviders.go create mode 100644 openstack/rms/v1/resources/ListResources.go create mode 100644 openstack/rms/v1/resources/ShowResourceById.go diff --git a/openstack/rms/v1/relations/ShowResourceRelations.go b/openstack/rms/v1/relations/ShowResourceRelations.go new file mode 100644 index 000000000..78aa8505e --- /dev/null +++ b/openstack/rms/v1/relations/ShowResourceRelations.go @@ -0,0 +1,64 @@ +package relations + +import ( + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" + "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" + "github.com/opentelekomcloud/gophertelekomcloud/openstack/rms/v1/resources" +) + +type ShowResourceRelationsOpts struct { + // Specifies the resource ID. + // Maximum length: 256 + ResourceId string + // Specifies the resource relationship direction. + // Possible values are as follows: + // - in + // - out + Direction string `q:"direction"` + // Specifies the maximum number of records to return. + // Minimum value: 1 + // Maximum value: 1000 + Limit *int32 `q:"limit,omitempty"` + // Specifies the pagination parameter. + // You can use the marker value returned in the previous request as the number of the first page of records to return in this request. + // Minimum length: 4 + // Maximum length: 400 + Marker string `q:"marker,omitempty"` +} + +func ShowResourceRelations(client *golangsdk.ServiceClient, opts ShowResourceRelationsOpts) (*ShowResourceRelationsResponse, error) { + q, err := golangsdk.BuildQueryString(opts) + if err != nil { + return nil, err + } + + // GET /v1/resource-manager/domains/{domain_id}/resources/{resource_id}/relations + raw, err := client.Get(client.ServiceURL("resources", opts.ResourceId, "relations")+q.String(), nil, nil) + if err != nil { + return nil, err + } + + var res ShowResourceRelationsResponse + err = extract.Into(raw.Body, &res) + return &res, err +} + +type ShowResourceRelationsResponse struct { + // Specifies the list of the resource relationships. + Relations []ResourceRelation `json:"relations,omitempty"` + // Specifies the pagination object. + PageInfo resources.PageInfo `json:"page_info,omitempty"` +} + +type ResourceRelation struct { + // Specifies the relationship type. + RelationType string `json:"relation_type,omitempty"` + // Specifies the type of the source resource. + FromResourceType string `json:"from_resource_type,omitempty"` + // Specifies the type of the associated resource. + ToResourceType string `json:"to_resource_type,omitempty"` + // Specifies the source resource ID. + FromResourceId string `json:"from_resource_id,omitempty"` + // Specifies the ID of the associated resource. + ToResourceId string `json:"to_resource_id,omitempty"` +} diff --git a/openstack/rms/v1/resources/ListAllResources.go b/openstack/rms/v1/resources/ListAllResources.go new file mode 100644 index 000000000..03cf26385 --- /dev/null +++ b/openstack/rms/v1/resources/ListAllResources.go @@ -0,0 +1,51 @@ +package resources + +import ( + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" + "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" +) + +type ListAllResourcesOpts struct { + // Specifies the region ID. + // Maximum length: 36 + RegionId string `q:"region_id,omitempty"` + // Specifies the enterprise project ID. + // Maximum length: 36 + EpId string `q:"ep_id,omitempty"` + // Specifies the resource type. + // Maximum length: 40 + Type string `q:"type,omitempty"` + // Specifies the maximum number of records to return. + // Minimum value: 1 + // Maximum value: 200 + Limit int32 `q:"limit,omitempty"` + // Specifies the pagination parameter. + // You can use the marker value returned in the previous request as the number of the first page of records to return in this request. + // Minimum length: 4 + // Maximum length: 400 + Marker int64 `q:"marker,omitempty"` +} + +func ListAllResources(client *golangsdk.ServiceClient, opts ListAllResourcesOpts) (*ListAllResourcesResponse, error) { + q, err := golangsdk.BuildQueryString(opts) + if err != nil { + return nil, err + } + + // GET /v1/resource-manager/domains/{domain_id}/all-resources + raw, err := client.Get(client.ServiceURL("all-resources")+q.String(), nil, nil) + if err != nil { + return nil, err + } + + var res ListAllResourcesResponse + err = extract.Into(raw.Body, &res) + return &res, err +} + +type ListAllResourcesResponse struct { + // Specifies the resource list + Resources []ResourceEntity `json:"resources,omitempty"` + // Specifies the pagination object. + PageInfo PageInfo `json:"page_info,omitempty"` +} diff --git a/openstack/rms/v1/resources/ListProviders.go b/openstack/rms/v1/resources/ListProviders.go new file mode 100644 index 000000000..2c46f51ab --- /dev/null +++ b/openstack/rms/v1/resources/ListProviders.go @@ -0,0 +1,75 @@ +package resources + +import ( + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" + "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" +) + +type ListProvidersOpts struct { + // Specifies the pagination offset. + // Minimum value: 1 + // Maximum value: 1000 + Offset *int32 `q:"offset,omitempty"` + // Specifies the maximum + // number of records to return. + // Minimum value: 1 + // Maximum value: 200 + Limit *int32 `q:"limit,omitempty"` +} + +func ListProviders(client *golangsdk.ServiceClient, opts ListProvidersOpts) (*ListProvidersResponse, error) { + q, err := golangsdk.BuildQueryString(opts) + if err != nil { + return nil, err + } + + // GET /v1/resource-manager/domains/{domain_id}/providers + raw, err := client.Get(client.ServiceURL("providers")+q.String(), nil, nil) + if err != nil { + return nil, err + } + + var res ListProvidersResponse + err = extract.Into(raw.Body, &res) + return &res, err +} + +type ListProvidersResponse struct { + // Specifies the list of cloud service details. + ResourceProviders *[]ResourceProviderResponse `json:"resource_providers,omitempty"` + // Specifies the total number of cloud services supported by RMS. + TotalCount *int32 `json:"total_count,omitempty"` +} + +type ResourceProviderResponse struct { + // Specifies the cloud service name. For details, see Supported Resource. + Provider string `json:"provider,omitempty"` + // Specifies the display name of the cloud service. + // You can set the language by configuring XLanguage in the request header + DisplayName string `json:"display_name,omitempty"` + // Specifies the display name of the cloud service category. + // You can set the language by configuring X-Language in the request header. + // Currently supported categories: Computing, Network, Storage, Database, Security, EI Enterprise. + CategoryDisplayName string `json:"category_display_name,omitempty"` + // Specifies the resource type list. + ResourceTypes []ResourceTypeResponse `json:"resource_types,omitempty"` +} + +type ResourceTypeResponse struct { + // Specifies the resource type. + Name string `json:"name,omitempty"` + // Specifies the display name of the resource type. + // You can set the language by configuring X-Language in the request header. + DisplayName string `json:"display_name,omitempty"` + // Specifies whether the resource is a global resource. + Global *bool `json:"global,omitempty"` + // Specifies the list of supported regions. + // Array of Strings. + Regions []string `json:"regions,omitempty"` + // Specifies the endpoint ID of the console. + ConsoleEndpointId string `json:"console_endpoint_id,omitempty"` + // Specifies the URL of the resource list page. + ConsoleListUrl string `json:"console_list_url,omitempty"` + // Specifies the URL of the resource details page. + ConsoleDetailUrl string `json:"console_detail_url,omitempty"` +} diff --git a/openstack/rms/v1/resources/ListResources.go b/openstack/rms/v1/resources/ListResources.go new file mode 100644 index 000000000..10e821223 --- /dev/null +++ b/openstack/rms/v1/resources/ListResources.go @@ -0,0 +1,100 @@ +package resources + +import ( + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" + "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" +) + +type ListResourcesOpts struct { + // Specifies the cloud service name. + // Maximum length: 20 + Provider string + // Specifies the resource type. + // Maximum length: 20 + Type string + // Specifies the region ID. + // Maximum length: 36 + RegionId string `q:"region_id,omitempty"` + // Specifies the enterprise project ID. + // Maximum length: 36 + EpId string `q:"ep_id,omitempty"` + // Specifies the resource tag. + Tag map[string]string `q:"tag,omitempty"` + // Specifies the maximum number of records to return. + // Minimum value: 1 + // Maximum value: 200 + Limit int32 `q:"limit,omitempty"` + // Specifies the pagination parameter. + // You can use the marker value returned in the previous request as the number of the first page of records to return in this request. + // Minimum length: 4 + // Maximum length: 400 + Marker int64 `q:"marker,omitempty"` +} + +func ListResources(client *golangsdk.ServiceClient, opts ListResourcesOpts) (*ListResourcesResponse, error) { + q, err := golangsdk.BuildQueryString(opts) + if err != nil { + return nil, err + } + + // GET /v1/resource-manager/domains/{domain_id}/provider/{provider}/type/{type}/resources + raw, err := client.Get(client.ServiceURL("provider", opts.Provider, "type", opts.Type, "resources")+q.String(), nil, nil) + if err != nil { + return nil, err + } + + var res ListResourcesResponse + err = extract.Into(raw.Body, &res) + return &res, err +} + +type ListResourcesResponse struct { + // Specifies the resource list + Resources []ResourceEntity `json:"resources,omitempty"` + // Specifies the pagination object. + PageInfo PageInfo `json:"page_info,omitempty"` +} + +type ResourceEntity struct { + // Specifies the resource ID. + Id string `json:"id,omitempty"` + // Specifies the resource name. + Name string `json:"name,omitempty"` + // Specifies the cloud service name. For details, see Supported Resource. + Provider string `json:"provider,omitempty"` + // Specifies the resource type. + Type string `json:"type,omitempty"` + // Specifies the region ID. + RegionId string `json:"region_id,omitempty"` + // Specifies the project ID in OpenStack. + ProjectId string `json:"project_id,omitempty"` + // Specifies the project name in OpenStack. + ProjectName string `json:"project_name,omitempty"` + // Specifies the enterprise project ID. + EpId string `json:"ep_id,omitempty"` + // Specifies the enterprise project name. + EpName string `json:"ep_name,omitempty"` + // Specifies the resource checksum. + Checksum string `json:"checksum,omitempty"` + // Specifies the time when the resource was created. + Created string `json:"created,omitempty"` + // Specifies the time when the resource was updated. + Updated string `json:"updated,omitempty"` + // Specifies the status of the operation that causes the resource change. + ProvisioningState string `json:"provisioning_state,omitempty"` + // Specifies the resource tags. + Tags map[string]string `json:"tags,omitempty"` + // Specifies the detailed properties of the resource. + Properties map[string]interface{} `json:"properties,omitempty"` +} + +type PageInfo struct { + // Specifies the resource quantity on the current page. + // Minimum value: 0 + // Maximum value: 200 + CurrentCount int32 `json:"current_count,omitempty"` + // Specifies the marker value of the next page. + // Minimum length: 4 + // Maximum length: 400 + NextMarker string `json:"next_marker,omitempty"` +} diff --git a/openstack/rms/v1/resources/ShowResourceById.go b/openstack/rms/v1/resources/ShowResourceById.go new file mode 100644 index 000000000..348a641f1 --- /dev/null +++ b/openstack/rms/v1/resources/ShowResourceById.go @@ -0,0 +1,30 @@ +package resources + +import ( + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" + "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" +) + +type ShowResourceByIdOpts struct { + // Specifies the cloud service name. + // Maximum length: 20 + Provider string + // Specifies the resource type. + // Maximum length: 20 + Type string + // Specifies the resource ID. + // Maximum length: 256 + ResourceId string +} + +func ShowResourceById(client *golangsdk.ServiceClient, opts ShowResourceByIdOpts) (*ResourceEntity, error) { + // GET /v1/resource-manager/domains/{domain_id}/provider/{provider}/type/{type}/resources/{resource_id} + raw, err := client.Get(client.ServiceURL("provider", opts.Provider, "type", opts.Type, "resources", opts.ResourceId), nil, nil) + if err != nil { + return nil, err + } + + var res ResourceEntity + err = extract.Into(raw.Body, &res) + return &res, err +} From f947c0d0a02815ab01f39c47db58a6a299b573fe Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Wed, 16 Nov 2022 14:21:39 +0100 Subject: [PATCH 2/6] fix --- acceptance/clients/clients.go | 8 ++++++++ acceptance/openstack/rms/v1/rms_test.go | 15 +++++++++++++++ openstack/client.go | 4 ++++ .../rms/v1/relations/ShowResourceRelations.go | 2 +- openstack/rms/v1/resources/ListAllResources.go | 2 +- openstack/rms/v1/resources/ListResources.go | 6 +++--- 6 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 acceptance/openstack/rms/v1/rms_test.go diff --git a/acceptance/clients/clients.go b/acceptance/clients/clients.go index 6fb71bf28..6efeb0215 100644 --- a/acceptance/clients/clients.go +++ b/acceptance/clients/clients.go @@ -484,6 +484,14 @@ func NewRdsV3() (*golangsdk.ServiceClient, error) { }) } +func NewRmsV1Client() (*golangsdk.ServiceClient, error) { + cc, err := CloudAndClient() + if err != nil { + return nil, err + } + return openstack.NewRMSV1(cc.ProviderClient, golangsdk.EndpointOpts{Region: cc.RegionName}) +} + // NewMrsV1 returns authenticated MRS v1 client func NewMrsV1() (*golangsdk.ServiceClient, error) { cc, err := CloudAndClient() diff --git a/acceptance/openstack/rms/v1/rms_test.go b/acceptance/openstack/rms/v1/rms_test.go new file mode 100644 index 000000000..7105123e8 --- /dev/null +++ b/acceptance/openstack/rms/v1/rms_test.go @@ -0,0 +1,15 @@ +package v1 + +import ( + "testing" + + "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" + th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" +) + +func TestRMS(t *testing.T) { + client, err := clients.NewRmsV1Client() + th.AssertNoErr(t, err) + + client.Get("resources", nil, nil) +} diff --git a/openstack/client.go b/openstack/client.go index 372630f72..a4ea55849 100644 --- a/openstack/client.go +++ b/openstack/client.go @@ -850,6 +850,10 @@ func NewRDSV3(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*gol return initClientOpts(client, eo, "rdsv3") } +func NewRMSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { + return initClientOpts(client, eo, "rms") +} + // NewSDRSV1 creates a ServiceClient that may be used with the v1 SDRS service. func NewSDRSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { return initClientOpts(client, eo, "sdrs") diff --git a/openstack/rms/v1/relations/ShowResourceRelations.go b/openstack/rms/v1/relations/ShowResourceRelations.go index 78aa8505e..017567b63 100644 --- a/openstack/rms/v1/relations/ShowResourceRelations.go +++ b/openstack/rms/v1/relations/ShowResourceRelations.go @@ -20,7 +20,7 @@ type ShowResourceRelationsOpts struct { // Maximum value: 1000 Limit *int32 `q:"limit,omitempty"` // Specifies the pagination parameter. - // You can use the marker value returned in the previous request as the number of the first page of records to return in this request. + // You can use the marker value returned to the previous request as the number of the first page of records to return in this request. // Minimum length: 4 // Maximum length: 400 Marker string `q:"marker,omitempty"` diff --git a/openstack/rms/v1/resources/ListAllResources.go b/openstack/rms/v1/resources/ListAllResources.go index 03cf26385..2f3381cb1 100644 --- a/openstack/rms/v1/resources/ListAllResources.go +++ b/openstack/rms/v1/resources/ListAllResources.go @@ -11,7 +11,7 @@ type ListAllResourcesOpts struct { RegionId string `q:"region_id,omitempty"` // Specifies the enterprise project ID. // Maximum length: 36 - EpId string `q:"ep_id,omitempty"` + EnterpriseProjectId string `q:"ep_id,omitempty"` // Specifies the resource type. // Maximum length: 40 Type string `q:"type,omitempty"` diff --git a/openstack/rms/v1/resources/ListResources.go b/openstack/rms/v1/resources/ListResources.go index 10e821223..1d835242e 100644 --- a/openstack/rms/v1/resources/ListResources.go +++ b/openstack/rms/v1/resources/ListResources.go @@ -17,7 +17,7 @@ type ListResourcesOpts struct { RegionId string `q:"region_id,omitempty"` // Specifies the enterprise project ID. // Maximum length: 36 - EpId string `q:"ep_id,omitempty"` + EnterpriseProjectId string `q:"ep_id,omitempty"` // Specifies the resource tag. Tag map[string]string `q:"tag,omitempty"` // Specifies the maximum number of records to return. @@ -71,9 +71,9 @@ type ResourceEntity struct { // Specifies the project name in OpenStack. ProjectName string `json:"project_name,omitempty"` // Specifies the enterprise project ID. - EpId string `json:"ep_id,omitempty"` + EnterpriseProjectId string `json:"ep_id,omitempty"` // Specifies the enterprise project name. - EpName string `json:"ep_name,omitempty"` + EnterpriseProjectName string `json:"ep_name,omitempty"` // Specifies the resource checksum. Checksum string `json:"checksum,omitempty"` // Specifies the time when the resource was created. From f97b160ac350b6d7081f3bf0f166b95fe92079ab Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Wed, 16 Nov 2022 14:24:32 +0100 Subject: [PATCH 3/6] fix --- openstack/rms/v1/resources/ListAllResources.go | 3 --- openstack/rms/v1/resources/ListResources.go | 7 ------- 2 files changed, 10 deletions(-) diff --git a/openstack/rms/v1/resources/ListAllResources.go b/openstack/rms/v1/resources/ListAllResources.go index 2f3381cb1..a41ca5840 100644 --- a/openstack/rms/v1/resources/ListAllResources.go +++ b/openstack/rms/v1/resources/ListAllResources.go @@ -9,9 +9,6 @@ type ListAllResourcesOpts struct { // Specifies the region ID. // Maximum length: 36 RegionId string `q:"region_id,omitempty"` - // Specifies the enterprise project ID. - // Maximum length: 36 - EnterpriseProjectId string `q:"ep_id,omitempty"` // Specifies the resource type. // Maximum length: 40 Type string `q:"type,omitempty"` diff --git a/openstack/rms/v1/resources/ListResources.go b/openstack/rms/v1/resources/ListResources.go index 1d835242e..3d3746b18 100644 --- a/openstack/rms/v1/resources/ListResources.go +++ b/openstack/rms/v1/resources/ListResources.go @@ -15,9 +15,6 @@ type ListResourcesOpts struct { // Specifies the region ID. // Maximum length: 36 RegionId string `q:"region_id,omitempty"` - // Specifies the enterprise project ID. - // Maximum length: 36 - EnterpriseProjectId string `q:"ep_id,omitempty"` // Specifies the resource tag. Tag map[string]string `q:"tag,omitempty"` // Specifies the maximum number of records to return. @@ -70,10 +67,6 @@ type ResourceEntity struct { ProjectId string `json:"project_id,omitempty"` // Specifies the project name in OpenStack. ProjectName string `json:"project_name,omitempty"` - // Specifies the enterprise project ID. - EnterpriseProjectId string `json:"ep_id,omitempty"` - // Specifies the enterprise project name. - EnterpriseProjectName string `json:"ep_name,omitempty"` // Specifies the resource checksum. Checksum string `json:"checksum,omitempty"` // Specifies the time when the resource was created. From 047efa35fe58f749bce69ce5a43858345b178da8 Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:27:54 +0100 Subject: [PATCH 4/6] NewRMSV1 --- openstack/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openstack/client.go b/openstack/client.go index a4ea55849..f17357e9a 100644 --- a/openstack/client.go +++ b/openstack/client.go @@ -851,7 +851,12 @@ func NewRDSV3(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*gol } func NewRMSV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { - return initClientOpts(client, eo, "rms") + sc, err := initClientOpts(client, eo, "rms") + if err != nil { + return nil, err + } + sc.ResourceBase = sc.Endpoint + "v1/resource-manager/domains/" + client.DomainID + "/" + return sc, err } // NewSDRSV1 creates a ServiceClient that may be used with the v1 SDRS service. From b857a7693fd63914f942e263bf37c5342101edc9 Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:54:27 +0100 Subject: [PATCH 5/6] clr --- .../rms/v1/relations/ShowResourceRelations.go | 2 +- openstack/rms/v1/resources/ListAllResources.go | 4 ++-- openstack/rms/v1/resources/ListProviders.go | 14 +++++++------- openstack/rms/v1/resources/ListResources.go | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openstack/rms/v1/relations/ShowResourceRelations.go b/openstack/rms/v1/relations/ShowResourceRelations.go index 017567b63..533ac2fcb 100644 --- a/openstack/rms/v1/relations/ShowResourceRelations.go +++ b/openstack/rms/v1/relations/ShowResourceRelations.go @@ -18,7 +18,7 @@ type ShowResourceRelationsOpts struct { // Specifies the maximum number of records to return. // Minimum value: 1 // Maximum value: 1000 - Limit *int32 `q:"limit,omitempty"` + Limit int `q:"limit,omitempty"` // Specifies the pagination parameter. // You can use the marker value returned to the previous request as the number of the first page of records to return in this request. // Minimum length: 4 diff --git a/openstack/rms/v1/resources/ListAllResources.go b/openstack/rms/v1/resources/ListAllResources.go index a41ca5840..024291639 100644 --- a/openstack/rms/v1/resources/ListAllResources.go +++ b/openstack/rms/v1/resources/ListAllResources.go @@ -15,12 +15,12 @@ type ListAllResourcesOpts struct { // Specifies the maximum number of records to return. // Minimum value: 1 // Maximum value: 200 - Limit int32 `q:"limit,omitempty"` + Limit int `q:"limit,omitempty"` // Specifies the pagination parameter. // You can use the marker value returned in the previous request as the number of the first page of records to return in this request. // Minimum length: 4 // Maximum length: 400 - Marker int64 `q:"marker,omitempty"` + Marker string `q:"marker,omitempty"` } func ListAllResources(client *golangsdk.ServiceClient, opts ListAllResourcesOpts) (*ListAllResourcesResponse, error) { diff --git a/openstack/rms/v1/resources/ListProviders.go b/openstack/rms/v1/resources/ListProviders.go index 2c46f51ab..2366d831f 100644 --- a/openstack/rms/v1/resources/ListProviders.go +++ b/openstack/rms/v1/resources/ListProviders.go @@ -9,12 +9,12 @@ type ListProvidersOpts struct { // Specifies the pagination offset. // Minimum value: 1 // Maximum value: 1000 - Offset *int32 `q:"offset,omitempty"` + Offset int `q:"offset,omitempty"` // Specifies the maximum // number of records to return. // Minimum value: 1 // Maximum value: 200 - Limit *int32 `q:"limit,omitempty"` + Limit int `q:"limit,omitempty"` } func ListProviders(client *golangsdk.ServiceClient, opts ListProvidersOpts) (*ListProvidersResponse, error) { @@ -36,12 +36,12 @@ func ListProviders(client *golangsdk.ServiceClient, opts ListProvidersOpts) (*Li type ListProvidersResponse struct { // Specifies the list of cloud service details. - ResourceProviders *[]ResourceProviderResponse `json:"resource_providers,omitempty"` + ResourceProviders []ResourceProvider `json:"resource_providers,omitempty"` // Specifies the total number of cloud services supported by RMS. - TotalCount *int32 `json:"total_count,omitempty"` + TotalCount int `json:"total_count,omitempty"` } -type ResourceProviderResponse struct { +type ResourceProvider struct { // Specifies the cloud service name. For details, see Supported Resource. Provider string `json:"provider,omitempty"` // Specifies the display name of the cloud service. @@ -52,10 +52,10 @@ type ResourceProviderResponse struct { // Currently supported categories: Computing, Network, Storage, Database, Security, EI Enterprise. CategoryDisplayName string `json:"category_display_name,omitempty"` // Specifies the resource type list. - ResourceTypes []ResourceTypeResponse `json:"resource_types,omitempty"` + ResourceTypes []ResourceType `json:"resource_types,omitempty"` } -type ResourceTypeResponse struct { +type ResourceType struct { // Specifies the resource type. Name string `json:"name,omitempty"` // Specifies the display name of the resource type. diff --git a/openstack/rms/v1/resources/ListResources.go b/openstack/rms/v1/resources/ListResources.go index 3d3746b18..1d02fd602 100644 --- a/openstack/rms/v1/resources/ListResources.go +++ b/openstack/rms/v1/resources/ListResources.go @@ -20,12 +20,12 @@ type ListResourcesOpts struct { // Specifies the maximum number of records to return. // Minimum value: 1 // Maximum value: 200 - Limit int32 `q:"limit,omitempty"` + Limit int `q:"limit,omitempty"` // Specifies the pagination parameter. // You can use the marker value returned in the previous request as the number of the first page of records to return in this request. // Minimum length: 4 // Maximum length: 400 - Marker int64 `q:"marker,omitempty"` + Marker string `q:"marker,omitempty"` } func ListResources(client *golangsdk.ServiceClient, opts ListResourcesOpts) (*ListResourcesResponse, error) { @@ -85,7 +85,7 @@ type PageInfo struct { // Specifies the resource quantity on the current page. // Minimum value: 0 // Maximum value: 200 - CurrentCount int32 `json:"current_count,omitempty"` + CurrentCount int `json:"current_count,omitempty"` // Specifies the marker value of the next page. // Minimum length: 4 // Maximum length: 400 From 83cf1aaf34c392d1c239b4f8f1c043622b3e9197 Mon Sep 17 00:00:00 2001 From: Aloento <11802769+Aloento@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:25:27 +0100 Subject: [PATCH 6/6] postponed --- acceptance/openstack/rms/v1/rms_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/acceptance/openstack/rms/v1/rms_test.go b/acceptance/openstack/rms/v1/rms_test.go index 7105123e8..bc79be051 100644 --- a/acceptance/openstack/rms/v1/rms_test.go +++ b/acceptance/openstack/rms/v1/rms_test.go @@ -4,6 +4,8 @@ import ( "testing" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" + "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" + "github.com/opentelekomcloud/gophertelekomcloud/openstack/rms/v1/resources" th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" ) @@ -11,5 +13,9 @@ func TestRMS(t *testing.T) { client, err := clients.NewRmsV1Client() th.AssertNoErr(t, err) - client.Get("resources", nil, nil) + all, err := resources.ListAllResources(client, resources.ListAllResourcesOpts{ + Limit: 1, + }) + th.AssertNoErr(t, err) + tools.PrintResource(t, all) }