github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cce/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  	// A prefix used by the server to generate a unique name ONLY IF the Name field has not been provided.
    27  	GenerateName string `json:"generateName,omitempty"`
    28  	// URL representing this object.
    29  	SelfLink string `json:"selfLink"`
    30  	UID      string `json:"uid"`
    31  	// String that identifies the server's internal version of this object that can be used by clients to determine when
    32  	// objects have changed.
    33  	ResourceVersion string `json:"resourceVersion"`
    34  	// An unstructured key value map stored with a resource that may be set by external tools to store and retrieve
    35  	// arbitrary metadata.
    36  	Annotations map[string]interface{} `json:"annotations"`
    37  	// Enabled identify whether the resource is available.
    38  	Enable bool `json:"enable"`
    39  	// Map of string keys and values that can be used to organize and categorize (scope and select) objects.
    40  	Labels map[string]interface{} `json:"labels"`
    41  	// An optional prefix used by the server to generate a unique name ONLY IF the Name field has not been provided.
    42  	Genetation        string `json:"generation"`
    43  	CreationTimestamp string `json:"creationTimestamp"`
    44  	DeletionTimestamp string `json:"DeletionTimestamp"`
    45  }
    46  
    47  // CreateResult represents a result of the Create method.
    48  type CreateResult struct {
    49  	commonResult
    50  }
    51  
    52  // GetResult represents a result of the Get method.
    53  type GetResult struct {
    54  	commonResult
    55  }
    56  
    57  // DeleteResult represents a result of the Delete method.
    58  type DeleteResult struct {
    59  	commonResult
    60  }
    61  
    62  func (r commonResult) Extract() (*Namespace, error) {
    63  	var s Namespace
    64  	err := r.ExtractInto(&s)
    65  	return &s, err
    66  }
    67  
    68  // NamespacePage represents a result of the List method.
    69  type NamespacePage struct {
    70  	pagination.SinglePageBase
    71  }
    72  
    73  // ExtractNamespaces is a method which to interpret the namespace pages as a namespace object list.
    74  func ExtractNamespaces(r pagination.Page) ([]Namespace, error) {
    75  	var s []Namespace
    76  	err := r.(NamespacePage).Result.ExtractIntoSlicePtr(&s, "items")
    77  	return s, err
    78  }