Skip to content

Commit aefd41b

Browse files
authored
make RelationshipCheck client functions (#578)
1 parent 942bb65 commit aefd41b

File tree

5 files changed

+96
-6
lines changed

5 files changed

+96
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Feature
2+
body: Add new client functions for `CreateCheckRelationship` and `UpdateCheckRelationship`
3+
time: 2025-07-31T11:01:19.557368-04:00

check.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var CheckCreateConstructors = map[CheckType]CheckInputConstructor{
3838
CheckTypeTagDefined: func() any { return &CheckTagDefinedCreateInput{} },
3939
CheckTypeToolUsage: func() any { return &CheckToolUsageCreateInput{} },
4040
CheckTypePackageVersion: func() any { return &CheckPackageVersionCreateInput{} },
41+
CheckTypeRelationship: func() any { return &CheckRelationshipCreateInput{} },
4142
}
4243

4344
var CheckUpdateConstructors = map[CheckType]CheckInputConstructor{
@@ -61,6 +62,7 @@ var CheckUpdateConstructors = map[CheckType]CheckInputConstructor{
6162
CheckTypeTagDefined: func() any { return &CheckTagDefinedUpdateInput{} },
6263
CheckTypeToolUsage: func() any { return &CheckToolUsageUpdateInput{} },
6364
CheckTypePackageVersion: func() any { return &CheckPackageVersionUpdateInput{} },
65+
CheckTypeRelationship: func() any { return &CheckRelationshipUpdateInput{} },
6466
}
6567

6668
func UnmarshalCheckCreateInput(checkType CheckType, data []byte) (any, error) {
@@ -164,6 +166,8 @@ func (client *Client) CreateCheck(input any) (*Check, error) {
164166
return client.CreateCheckToolUsage(*v)
165167
case *CheckPackageVersionCreateInput:
166168
return client.CreateCheckPackageVersion(*v)
169+
case *CheckRelationshipCreateInput:
170+
return client.CreateCheckRelationship(*v)
167171
}
168172
return nil, fmt.Errorf("unknown input type %T", input)
169173
}
@@ -252,6 +256,8 @@ func (client *Client) UpdateCheck(input any) (*Check, error) {
252256
return client.UpdateCheckToolUsage(*v)
253257
case *CheckPackageVersionUpdateInput:
254258
return client.UpdateCheckPackageVersion(*v)
259+
case *CheckRelationshipUpdateInput:
260+
return client.UpdateCheckRelationship(*v)
255261
}
256262
return nil, fmt.Errorf("unknown input type %T", input)
257263
}

check_relationship.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package opslevel
2+
3+
type RelationshipCheckFragment struct {
4+
RelationshipCountPredicate *Predicate `graphql:"relationshipCountPredicate"` // The condition that should be satisfied by the number of RelatedTo relationships
5+
RelationshipDefinition RelationshipDefinitionType `graphql:"relationshipDefinition"` // The relationship definition that the check is based on.
6+
}
7+
8+
func (client *Client) CreateCheckRelationship(input CheckRelationshipCreateInput) (*Check, error) {
9+
var m struct {
10+
Payload CheckResponsePayload `graphql:"checkRelationshipCreate(input: $input)"`
11+
}
12+
v := PayloadVariables{
13+
"input": input,
14+
}
15+
err := client.Mutate(&m, v, WithName("CheckRelationshipCreate"))
16+
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors)
17+
}
18+
19+
func (client *Client) UpdateCheckRelationship(input CheckRelationshipUpdateInput) (*Check, error) {
20+
var m struct {
21+
Payload CheckResponsePayload `graphql:"checkRelationshipUpdate(input: $input)"`
22+
}
23+
v := PayloadVariables{
24+
"input": input,
25+
}
26+
err := client.Mutate(&m, v, WithName("CheckRelationshipUpdate"))
27+
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors)
28+
}

0 commit comments

Comments
 (0)