Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] RMS #468

Draft
wants to merge 6 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions openstack/rms/v1/relations/ShowResourceRelations.go
Original file line number Diff line number Diff line change
@@ -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"`
}
51 changes: 51 additions & 0 deletions openstack/rms/v1/resources/ListAllResources.go
Original file line number Diff line number Diff line change
@@ -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"`
}
75 changes: 75 additions & 0 deletions openstack/rms/v1/resources/ListProviders.go
Original file line number Diff line number Diff line change
@@ -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"`
}
100 changes: 100 additions & 0 deletions openstack/rms/v1/resources/ListResources.go
Original file line number Diff line number Diff line change
@@ -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"`
Aloento marked this conversation as resolved.
Show resolved Hide resolved
// 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"`
Aloento marked this conversation as resolved.
Show resolved Hide resolved
// 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"`
}
30 changes: 30 additions & 0 deletions openstack/rms/v1/resources/ShowResourceById.go
Original file line number Diff line number Diff line change
@@ -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
}