-
Notifications
You must be signed in to change notification settings - Fork 54
/
space.go
37 lines (31 loc) · 982 Bytes
/
space.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
package payloads
import (
"code.cloudfoundry.org/korifi/api/repositories"
)
type SpaceCreate struct {
Name string `json:"name" validate:"required"`
Relationships SpaceRelationships `json:"relationships" validate:"required"`
Metadata Metadata `json:"metadata"`
}
type SpaceRelationships struct {
Org Relationship `json:"organization" validate:"required"`
}
func (p SpaceCreate) ToMessage() repositories.CreateSpaceMessage {
return repositories.CreateSpaceMessage{
Name: p.Name,
OrganizationGUID: p.Relationships.Org.Data.GUID,
}
}
type SpacePatch struct {
Metadata MetadataPatch `json:"metadata"`
}
func (p SpacePatch) ToMessage(spaceGUID, orgGUID string) repositories.PatchSpaceMetadataMessage {
return repositories.PatchSpaceMetadataMessage{
GUID: spaceGUID,
OrgGUID: orgGUID,
MetadataPatch: repositories.MetadataPatch{
Labels: p.Metadata.Labels,
Annotations: p.Metadata.Annotations,
},
}
}