github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cci/v1/namespaces/results.go (about)

     1  package namespaces
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  	"github.com/chnsz/golangsdk/pagination"
     6  )
     7  
     8  type commonResult struct {
     9  	golangsdk.Result
    10  }
    11  
    12  // Namespace is a struct that represents the result of Create and Get methods.
    13  type Namespace struct {
    14  	// Standard object metadata.
    15  	Metadata MetaResp `json:"metadata"`
    16  	// Spec defines the behavior of the Namespace.
    17  	Spec Spec `json:"spec"`
    18  	// Status describes the current status of a Namespace.
    19  	Status Status `json:"status"`
    20  }
    21  
    22  // MetaResp is a standard object metadata.
    23  type MetaResp struct {
    24  	// Namespace name.
    25  	Name string `json:"name"`
    26  	// URL representing this object.
    27  	SelfLink string `json:"selfLink"`
    28  	UID      string `json:"uid"`
    29  	// String that identifies the server's internal version of this object that can be used by clients to determine when
    30  	// objects have changed.
    31  	ResourceVersion string `json:"resourceVersion"`
    32  	// An unstructured key value map stored with a resource that may be set by external tools to store and retrieve
    33  	// arbitrary metadata.
    34  	Annotations AnnotationsResp `json:"annotations"`
    35  	// Enabled identify whether the resource is available.
    36  	Enable bool `json:"enable"`
    37  	// Map of string keys and values that can be used to organize and categorize (scope and select) objects.
    38  	Labels Labels `json:"labels"`
    39  	// An optional prefix used by the server to generate a unique name ONLY IF the Name field has not been provided.
    40  	Genetation        string `json:"generation"`
    41  	CreationTimestamp string `json:"creationTimestamp"`
    42  	DeletionTimestamp string `json:"DeletionTimestamp"`
    43  }
    44  
    45  // AnnotationsResp is an object of unstructured key value map.
    46  type AnnotationsResp struct {
    47  	// Whether to enable elastic scheduling.
    48  	AutoExpend bool `json:"namespace.kubernetes.io/allowed-on-shared-node,string"`
    49  	// Flavor of the cluster to which the namespace belongs.
    50  	Flavor string `json:"namespace.kubernetes.io/flavor"`
    51  	// Indicates whether to support dynamic storage creation.
    52  	DynamicProvision string `json:"pv.kubernetes.io/enable-dynamic-provisioning"`
    53  	// Account ID.
    54  	DomainID string `json:"tenant.kubernetes.io/domain-id"`
    55  	// Account name.
    56  	DomainName string `json:"tenant.kubernetes.io/domain-name"`
    57  	// Project ID.
    58  	ProjectID string `json:"tenant.kubernetes.io/project-id"`
    59  	// Project name.
    60  	ProjectName string `json:"tenant.kubernetes.io/project-name"`
    61  	// Whether to enable container network.
    62  	NetworkEnable string `json:"network.cci.io/ready-before-pod-run"`
    63  	// IP Pool Warm-up for Namespace.
    64  	PoolSize int `json:"network.cci.io/warm-pool-size,string"`
    65  	// IP Address Recycling Interval, in hour.
    66  	RecyclingInterval int `json:"network.cci.io/warm-pool-recycle-interval,string"`
    67  }
    68  
    69  // CreateResult represents a result of the Create method.
    70  type CreateResult struct {
    71  	commonResult
    72  }
    73  
    74  // GetResult represents a result of the Get method.
    75  type GetResult struct {
    76  	commonResult
    77  }
    78  
    79  // DeleteResult represents a result of the Delete method.
    80  type DeleteResult struct {
    81  	commonResult
    82  }
    83  
    84  func (r commonResult) Extract() (*Namespace, error) {
    85  	var s Namespace
    86  	err := r.ExtractInto(&s)
    87  	return &s, err
    88  }
    89  
    90  // NamespacePage represents a result of the List method.
    91  type NamespacePage struct {
    92  	pagination.SinglePageBase
    93  }
    94  
    95  // ExtractNamespaces is a method which to interpret the namespace pages as a namespace object list.
    96  func ExtractNamespaces(r pagination.Page) ([]Namespace, error) {
    97  	var s []Namespace
    98  	err := r.(NamespacePage).Result.ExtractIntoSlicePtr(&s, "items")
    99  	return s, err
   100  }