github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/model/destination.go (about) 1 package model 2 3 import ( 4 "errors" 5 6 "github.com/kyma-incubator/compass/components/director/internal/domain/destination/destinationcreator" 7 ) 8 9 // DestinationInput missing godoc 10 type DestinationInput struct { 11 Name string `json:"Name"` 12 Type string `json:"Type"` 13 URL string `json:"URL"` 14 Authentication string `json:"Authentication"` 15 XCorrelationID string `json:"x-correlation-id"` 16 XSystemTenantID string `json:"x-system-id"` 17 XSystemTenantName string `json:"x-system-name"` 18 XSystemType string `json:"x-system-type"` 19 XSystemBaseURL string `json:"x-system-base-url"` 20 } 21 22 // Destination is an internal model representation of the destination entity 23 type Destination struct { 24 ID string `json:"id"` 25 Name string `json:"name"` 26 Type destinationcreator.Type `json:"type"` 27 URL string `json:"url"` 28 Authentication destinationcreator.AuthType `json:"authentication"` 29 SubaccountID string `json:"subaccount_id"` 30 FormationAssignmentID *string `json:"formationAssignmentID"` 31 } 32 33 // Validate returns error if system doesn't have the required properties 34 func (d *DestinationInput) Validate() error { 35 if d.XCorrelationID == "" { 36 return errors.New("missing destination correlation id") 37 } 38 39 hasSystemIDAndType := d.XSystemTenantID != "" && d.XSystemType != "" 40 hasNameAndURL := d.XSystemBaseURL != "" && d.XSystemTenantName != "" 41 42 if !hasSystemIDAndType && !hasNameAndURL { 43 return errors.New("missing destination tenant information") 44 } 45 return nil 46 }