github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cce/v3/partitions/results.go (about)

     1  package partitions
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  )
     6  
     7  // Describes the Partition Structure of cluster
     8  type ListPartition struct {
     9  	// API type, fixed value "List"
    10  	Kind string `json:"kind"`
    11  	// API version, fixed value "v3"
    12  	Apiversion string `json:"apiVersion"`
    13  	// all Clusters
    14  	Partitions []Partitions `json:"items"`
    15  }
    16  
    17  // Individual partitions of the cluster
    18  type Partitions struct {
    19  	// API type, fixed value " Host "
    20  	Kind string `json:"kind"`
    21  	// API version, fixed value v3
    22  	Apiversion string `json:"apiVersion"`
    23  	// Partition metadata
    24  	Metadata Metadata `json:"metadata"`
    25  	// Partition detailed parameters
    26  	Spec Spec `json:"spec"`
    27  }
    28  
    29  // Metadata required to create a partition
    30  type Metadata struct {
    31  	// Partition name
    32  	Name string `json:"name"`
    33  }
    34  
    35  // Spec describes Partitions specification
    36  type Spec struct {
    37  	// The category of partition
    38  	Category string `json:"category,omitempty"`
    39  	// The availability zone name of the partition
    40  	PublicBorderGroup string `json:"publicBorderGroup,omitempty"`
    41  	// The default host network for the partition
    42  	HostNetwork HostNetwork `json:"hostNetwork,omitempty"`
    43  	// The default host network for the partition container
    44  	ContainerNetwork []ContainerNetwork `json:"containerNetwork,omitempty"`
    45  }
    46  
    47  // HostNetwork the default host network for the partition
    48  type HostNetwork struct {
    49  	// The default SubnetID for the partition
    50  	SubnetID string `json:"subnetID,omitempty"`
    51  }
    52  
    53  // ContainerNetwork the default host network for the partition container
    54  type ContainerNetwork struct {
    55  	// The default SubnetID for the partition container
    56  	SubnetID string `json:"subnetID,omitempty"`
    57  }
    58  
    59  type commonResult struct {
    60  	golangsdk.Result
    61  }
    62  
    63  // Extract is a function that accepts a result and extracts a partition.
    64  func (r commonResult) Extract() (*Partitions, error) {
    65  	var s Partitions
    66  	err := r.ExtractInto(&s)
    67  	return &s, err
    68  }
    69  
    70  // ExtractPartitions is a function that accepts a ListOpts struct, which allows you to filter and sort
    71  // the returned collection for greater efficiency.
    72  func (r commonResult) ExtractPartitions() ([]Partitions, error) {
    73  	var s ListPartition
    74  	err := r.ExtractInto(&s)
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  
    79  	return s.Partitions, nil
    80  }
    81  
    82  // ListResult represents the result of a list operation. Call its ExtractCluster
    83  // method to interpret it as a Cluster.
    84  type ListResult struct {
    85  	commonResult
    86  }
    87  
    88  // CreateResult represents the result of a create operation. Call its Extract
    89  // method to interpret it as a Cluster.
    90  type CreateResult struct {
    91  	commonResult
    92  }
    93  
    94  // GetResult represents the result of a get operation. Call its Extract
    95  // method to interpret it as a Cluster.
    96  type GetResult struct {
    97  	commonResult
    98  }
    99  
   100  // UpdateResult represents the result of an update operation. Call its Extract
   101  // method to interpret it as a Cluster.
   102  type UpdateResult struct {
   103  	commonResult
   104  }
   105  
   106  // DeleteResult represents the result of a delete operation. Call its ExtractErr
   107  // method to determine if the request succeeded or failed.
   108  type DeleteResult struct {
   109  	golangsdk.ErrResult
   110  }