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

     1  package model
     2  
     3  import (
     4  	"github.com/kyma-incubator/compass/components/director/pkg/pagination"
     5  	"github.com/kyma-incubator/compass/components/director/pkg/resource"
     6  )
     7  
     8  // Document missing godoc
     9  type Document struct {
    10  	BundleID                     string
    11  	AppID                        *string
    12  	ApplicationTemplateVersionID *string
    13  	Title                        string
    14  	DisplayName                  string
    15  	Description                  string
    16  	Format                       DocumentFormat
    17  	// for example Service Class, API etc
    18  	Kind *string
    19  	Data *string
    20  	*BaseEntity
    21  }
    22  
    23  // GetType missing godoc
    24  func (*Document) GetType() resource.Type {
    25  	return resource.Document
    26  }
    27  
    28  // DocumentInput missing godoc
    29  type DocumentInput struct {
    30  	Title        string
    31  	DisplayName  string
    32  	Description  string
    33  	Format       DocumentFormat
    34  	Kind         *string
    35  	Data         *string
    36  	FetchRequest *FetchRequestInput
    37  }
    38  
    39  // DocumentFormat missing godoc
    40  type DocumentFormat string
    41  
    42  // DocumentFormatMarkdown missing godoc
    43  const (
    44  	DocumentFormatMarkdown DocumentFormat = "MARKDOWN"
    45  )
    46  
    47  // DocumentPage missing godoc
    48  type DocumentPage struct {
    49  	Data       []*Document
    50  	PageInfo   *pagination.Page
    51  	TotalCount int
    52  }
    53  
    54  // ToDocumentWithinBundle missing godoc
    55  func (d *DocumentInput) ToDocumentWithinBundle(id, bundleID string, resourceType resource.Type, resourceID string) *Document {
    56  	if d == nil {
    57  		return nil
    58  	}
    59  
    60  	doc := &Document{
    61  		BundleID:    bundleID,
    62  		Title:       d.Title,
    63  		DisplayName: d.DisplayName,
    64  		Description: d.Description,
    65  		Format:      d.Format,
    66  		Kind:        d.Kind,
    67  		Data:        d.Data,
    68  		BaseEntity: &BaseEntity{
    69  			ID:    id,
    70  			Ready: true,
    71  		},
    72  	}
    73  
    74  	if resourceType.IsTenantIgnorable() {
    75  		doc.ApplicationTemplateVersionID = &resourceID
    76  	} else if resourceType == resource.Application {
    77  		doc.AppID = &resourceID
    78  	}
    79  
    80  	return doc
    81  }