github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/model/vendor.go (about)

     1  package model
     2  
     3  import (
     4  	"encoding/json"
     5  	"github.com/kyma-incubator/compass/components/director/pkg/resource"
     6  )
     7  
     8  // Vendor missing godoc
     9  type Vendor struct {
    10  	ID                           string
    11  	OrdID                        string
    12  	ApplicationID                *string
    13  	ApplicationTemplateVersionID *string
    14  	Title                        string
    15  	Partners                     json.RawMessage
    16  	Tags                         json.RawMessage
    17  	Labels                       json.RawMessage
    18  	DocumentationLabels          json.RawMessage
    19  }
    20  
    21  // VendorInput missing godoc
    22  type VendorInput struct {
    23  	OrdID               string          `json:"ordId"`
    24  	Title               string          `json:"title"`
    25  	Partners            json.RawMessage `json:"partners"`
    26  	Tags                json.RawMessage `json:"tags"`
    27  	Labels              json.RawMessage `json:"labels"`
    28  	DocumentationLabels json.RawMessage `json:"documentationLabels"`
    29  }
    30  
    31  // ToVendor missing godoc
    32  func (i *VendorInput) ToVendor(id string, resourceType resource.Type, resourceID string) *Vendor {
    33  	if i == nil {
    34  		return nil
    35  	}
    36  
    37  	vendor := &Vendor{
    38  		ID:                  id,
    39  		OrdID:               i.OrdID,
    40  		Title:               i.Title,
    41  		Partners:            i.Partners,
    42  		Tags:                i.Tags,
    43  		Labels:              i.Labels,
    44  		DocumentationLabels: i.DocumentationLabels,
    45  	}
    46  
    47  	if resourceType == resource.ApplicationTemplateVersion {
    48  		vendor.ApplicationTemplateVersionID = &resourceID
    49  	} else if resourceType == resource.Application {
    50  		vendor.ApplicationID = &resourceID
    51  	}
    52  
    53  	return vendor
    54  }
    55  
    56  // SetFromUpdateInput missing godoc
    57  func (p *Vendor) SetFromUpdateInput(update VendorInput) {
    58  	p.Title = update.Title
    59  	p.Partners = update.Partners
    60  	p.Tags = update.Tags
    61  	p.Labels = update.Labels
    62  	p.DocumentationLabels = update.DocumentationLabels
    63  }