github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/elb/certificate/results.go (about)

     1  package certificate
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  /*
     8  type CreateResponse struct {
     9  	TenantId    string `json:"tenant_id"`
    10  	Id          string `json:"id"`
    11  	Name        string `json:"name"`
    12  	Description string `json:"description"`
    13  	Domain      string `json:"domain"`
    14  	Certificate string `json:"certificate"`
    15  	PrivateKey  string `json:"private_key"`
    16  	CreateTime  string `json:"create_time"`
    17  	UpdateTime  string `json:"update_time"`
    18  }
    19  */
    20  type Certificate struct {
    21  	ID          string `json:"id"`
    22  	Name        string `json:"name"`
    23  	Description string `json:"description"`
    24  	Domain      string `json:"domain"`
    25  	Certificate string `json:"certificate"`
    26  	PrivateKey  string `json:"private_key"`
    27  	CreateTime  string `json:"create_time"`
    28  	UpdateTime  string `json:"update_time"`
    29  }
    30  
    31  type commonResult struct {
    32  	golangsdk.Result
    33  }
    34  
    35  func (r commonResult) Extract() (*Certificate, error) {
    36  	s := &Certificate{}
    37  	return s, r.ExtractInto(s)
    38  }
    39  
    40  type CreateResult struct {
    41  	commonResult
    42  }
    43  
    44  // DeleteResult represents the result of a delete operation.
    45  type DeleteResult struct {
    46  	golangsdk.ErrResult
    47  }
    48  
    49  type getResponse struct {
    50  	Certificates []Certificate `json:"certificates"`
    51  	InstanceNum  string        `json:"instance_num"`
    52  }
    53  
    54  // GetResult represents the result of a get operation.
    55  type GetResult struct {
    56  	ID string
    57  	golangsdk.Result
    58  }
    59  
    60  func (r GetResult) Extract() (*Certificate, error) {
    61  	s := &getResponse{}
    62  	err := r.ExtractInto(s)
    63  	if err == nil {
    64  		for _, c := range s.Certificates {
    65  			if c.ID == r.ID {
    66  				return &c, nil
    67  			}
    68  		}
    69  		return nil, golangsdk.ErrDefault404{}
    70  	}
    71  	return nil, err
    72  }
    73  
    74  type UpdateResult struct {
    75  	commonResult
    76  }