github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/vpc/v3/vpcs/Get.go (about)

     1  package vpcs
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack"
     7  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     8  )
     9  
    10  // Get retrieves a particular VPC based on its unique ID.
    11  func Get(client *golangsdk.ServiceClient, id string) (*Vpc, error) {
    12  	// GET /v3/{project_id}/vpc/vpcs/{vpc_id}
    13  	raw, err := client.Get(client.ServiceURL("vpcs", id), nil, openstack.StdRequestOpts())
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  
    18  	var res Vpc
    19  	err = extract.IntoStructPtr(raw.Body, &res, "vpc")
    20  	return &res, err
    21  }
    22  
    23  type CloudResource struct {
    24  	// Resource type
    25  	ResourceType string `json:"resource_type"`
    26  	// Number of resources
    27  	ResourceCount int `json:"resource_count"`
    28  }
    29  
    30  type Vpc struct {
    31  	// VPC ID, which uniquely identifies the VPC
    32  	// The value is in UUID format with hyphens (-).
    33  	Id string `json:"id"`
    34  	// VPC name
    35  	// The value can contain no more than 64 characters, including letters,
    36  	// digits, underscores (_), hyphens (-), and periods (.).
    37  	Name string `json:"name"`
    38  	// Provides supplementary information about the VPC.
    39  	// The value can contain no more than 255 characters and cannot contain angle brackets (< or >).
    40  	Description string `json:"description"`
    41  	// Available VPC CIDR blocks
    42  	// Value range:
    43  	// 10.0.0.0/8-10.255.255.240/28
    44  	// 172.16.0.0/12-172.31.255.240/28
    45  	// 192.168.0.0/16-192.168.255.240/28
    46  	// If cidr is not specified, the default value is "".
    47  	// The value must be in IPv4 CIDR format, for example, 192.168.0.0/16.
    48  	Cidr string `json:"cidr"`
    49  	// Secondary CIDR blocks of VPCs
    50  	// Currently, only IPv4 CIDR blocks are supported.
    51  	SecondaryCidrs []string `json:"extend_cidrs"`
    52  	// VPC status
    53  	// Value range:
    54  	// PENDING: The VPC is being created.
    55  	// ACTIVE: The VPC is created successfully.
    56  	Status string `json:"status"`
    57  	// ID of the project to which the VPC belongs
    58  	ProjectId string `json:"project_id"`
    59  	// Time when the VPC is created
    60  	// UTC time in the format of yyyy-MM-ddTHH:mmss
    61  	CreatedAt string `json:"created_at"`
    62  	// Time when the VPC is updated
    63  	// UTC time in the format of yyyy-MM-ddTHH:mmss
    64  	UpdatedAt string `json:"updated_at"`
    65  	// Type and number of resources associated with the VPC
    66  	// Currently, only route tables and subnets of the VPC are returned.
    67  	// The number of virsubnets is the total number of IPv4 and IPv6 subnets.
    68  	CloudResources []CloudResource `json:"cloud_resources"`
    69  	// VPC tags. For details, see the tag objects.
    70  	// Value range: 0 to 10 tag key-value pairs
    71  	Tags []tags.ResourceTag `json:"tags"`
    72  }