-
Notifications
You must be signed in to change notification settings - Fork 56
/
service_instance.go
51 lines (43 loc) · 1.7 KB
/
service_instance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package payloads
import (
"strings"
"code.cloudfoundry.org/korifi/api/repositories"
)
type ServiceInstanceCreate struct {
Name string `json:"name" validate:"required"`
Type string `json:"type" validate:"required,oneof=user-provided"`
Tags []string `json:"tags" validate:"serviceinstancetaglength"`
Credentials map[string]string `json:"credentials"`
Relationships ServiceInstanceRelationships `json:"relationships" validate:"required"`
Metadata Metadata `json:"metadata"`
}
type ServiceInstanceRelationships struct {
Space Relationship `json:"space" validate:"required"`
}
func (p ServiceInstanceCreate) ToServiceInstanceCreateMessage() repositories.CreateServiceInstanceMessage {
return repositories.CreateServiceInstanceMessage{
Name: p.Name,
SpaceGUID: p.Relationships.Space.Data.GUID,
Credentials: p.Credentials,
Type: p.Type,
Tags: p.Tags,
Labels: p.Metadata.Labels,
Annotations: p.Metadata.Annotations,
}
}
type ServiceInstanceList struct {
Names *string `schema:"names"`
SpaceGuids *string `schema:"space_guids"`
OrderBy string `schema:"order_by"`
}
func (l *ServiceInstanceList) ToMessage() repositories.ListServiceInstanceMessage {
return repositories.ListServiceInstanceMessage{
Names: ParseArrayParam(l.Names),
SpaceGuids: ParseArrayParam(l.SpaceGuids),
OrderBy: strings.TrimPrefix(l.OrderBy, "-"),
DescendingOrder: strings.HasPrefix(l.OrderBy, "-"),
}
}
func (l *ServiceInstanceList) SupportedFilterKeys() []string {
return []string{"names", "space_guids", "fields", "order_by", "per_page"}
}