github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rts/v1/softwaredeployment/results.go (about)

     1  package softwaredeployment
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  type Deployment struct {
     9  	// Specifies the stack action that triggers this deployment resource.
    10  	Action string `json:"action"`
    11  	//Specifies the ID of the software Deployments resource running on an instance.
    12  	ConfigId string `json:"config_id"`
    13  	//Specifies the creation time. The timestamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm
    14  	CreationTime golangsdk.JSONRFC3339NoZ `json:"creation_time"`
    15  	//Specifies the ID of this deployment resource.
    16  	Id string `json:"id"`
    17  	//Specifies input data stored in the form of a key-value pair.
    18  	InputValues map[string]interface{} `json:"input_values"`
    19  	//Specifies output data stored in the form of a key-value pair.
    20  	OutputValues map[string]interface{} `json:"output_values"`
    21  	//Specifies the ID of the instance deployed by the software Deployments.
    22  	ServerId string `json:"server_id"`
    23  	//Specifies the current status of deployment resources. Valid values include COMPLETE, IN_PROGRESS, and FAILED.
    24  	Status string `json:"status"`
    25  	//Specifies the cause of the current deployment resource status.
    26  	StatusReason string `json:"status_reason"`
    27  	//Specifies the updated time. The timestamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm
    28  	UpdatedTime golangsdk.JSONRFC3339NoZ `json:"updated_time"`
    29  }
    30  
    31  // DeploymentPage is the page returned by a pager when traversing over a
    32  // collection of Software Deployments.
    33  type DeploymentPage struct {
    34  	pagination.LinkedPageBase
    35  }
    36  
    37  // NextPageURL is invoked when a paginated collection of Software Deployments has reached
    38  // the end of a page and the pager seeks to traverse over a new one. In order
    39  // to do this, it needs to construct the next page's URL.
    40  func (r DeploymentPage) NextPageURL() (string, error) {
    41  	var s struct {
    42  		Links []golangsdk.Link `json:"software_deployments_links"`
    43  	}
    44  	err := r.ExtractInto(&s)
    45  	if err != nil {
    46  		return "", err
    47  	}
    48  	return golangsdk.ExtractNextURL(s.Links)
    49  }
    50  
    51  // IsEmpty checks whether a DeploymentPage struct is empty.
    52  func (r DeploymentPage) IsEmpty() (bool, error) {
    53  	is, err := ExtractDeployments(r)
    54  	return len(is) == 0, err
    55  }
    56  
    57  // ExtractDeployments accepts a Page struct, specifically a DeploymentPage struct,
    58  // and extracts the elements into a slice of Software Deployments structs. In other words,
    59  // a generic collection is mapped into a relevant slice.
    60  func ExtractDeployments(r pagination.Page) ([]Deployment, error) {
    61  	var s struct {
    62  		Deployments []Deployment `json:"software_deployments"`
    63  	}
    64  	err := (r.(DeploymentPage)).ExtractInto(&s)
    65  	return s.Deployments, err
    66  }
    67  
    68  type commonResult struct {
    69  	golangsdk.Result
    70  }
    71  
    72  // Extract is a function that accepts a result and extracts a Software Deployments.
    73  func (r commonResult) Extract() (*Deployment, error) {
    74  	var s struct {
    75  		SoftwareDeployment *Deployment `json:"software_deployment"`
    76  	}
    77  	err := r.ExtractInto(&s)
    78  	return s.SoftwareDeployment, err
    79  }
    80  
    81  // CreateResult represents the result of a create operation. Call its Extract
    82  // method to interpret it as a Software Deployments.
    83  type CreateResult struct {
    84  	commonResult
    85  }
    86  
    87  // GetResult represents the result of a get operation. Call its Extract
    88  // method to interpret it as a Software Deployments.
    89  type GetResult struct {
    90  	commonResult
    91  }
    92  
    93  // UpdateResult represents the result of an update operation. Call its Extract
    94  // method to interpret it as a Software Deployments.
    95  type UpdateResult struct {
    96  	commonResult
    97  }
    98  
    99  // DeleteResult represents the result of a delete operation. Call its ExtractErr
   100  // method to determine if the request succeeded or failed.
   101  type DeleteResult struct {
   102  	golangsdk.ErrResult
   103  }