github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/servicestage/v2/components/results.go (about)

     1  package components
     2  
     3  import "github.com/chnsz/golangsdk/pagination"
     4  
     5  // Component is the structure that represents the detail of the application component.
     6  type Component struct {
     7  	// Application component ID.
     8  	ID string `json:"id"`
     9  	// Application component name.
    10  	Name string `json:"name"`
    11  	// Value: 0 or 1.
    12  	// 0: Normal.
    13  	// 1: Being deleted.
    14  	Status int `json:"status"`
    15  	// Runtime.
    16  	Runtime string `json:"runtime"`
    17  	// Application component type. Example: Webapp, MicroService, or Common.
    18  	Type string `json:"category"`
    19  	// Application component sub-type.
    20  	// Webapp sub-types include Web.
    21  	// MicroService sub-types include Java Chassis, Go Chassis, Mesher, Spring Cloud, and Dubbo.
    22  	// Common sub-type can be empty.
    23  	Framwork string `json:"sub_category"`
    24  	// Description.
    25  	Description string `json:"description"`
    26  	// Project ID.
    27  	ProjectId string `json:"project_id"`
    28  	// Application ID.
    29  	ApplicationId string `json:"application_id"`
    30  	// Source of the code or software package.
    31  	Source Source `json:"source"`
    32  	// Component Builder.
    33  	Builder Builder `json:"build"`
    34  	// Pipeline ID list. A maximum of 10 pipeline IDs are supported.
    35  	PipelineIds []string `json:"pipeline_ids"`
    36  	// Creation time.
    37  	CreatedAt int `json:"create_time"`
    38  	// Update time.
    39  	UpdatedAt int `json:"update_time"`
    40  	// Creator.
    41  	Creator string `json:"creator"`
    42  }
    43  
    44  // ComponentPage is a single page maximum result representing a query by offset page.
    45  type ComponentPage struct {
    46  	pagination.OffsetPageBase
    47  }
    48  
    49  // IsEmpty checks whether a ComponentPage struct is empty.
    50  func (b ComponentPage) IsEmpty() (bool, error) {
    51  	arr, err := ExtractComponents(b)
    52  	return len(arr) == 0, err
    53  }
    54  
    55  // ExtractComponents is a method to extract the list of component details for ServiceStage service.
    56  func ExtractComponents(r pagination.Page) ([]Component, error) {
    57  	var s []Component
    58  	err := r.(ComponentPage).Result.ExtractIntoSlicePtr(&s, "components")
    59  	return s, err
    60  }