-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from OpsLevel/kr/check-input-refactor
refactor check input constructors to make more grokable codebase
- Loading branch information
Showing
18 changed files
with
862 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package opslevel | ||
|
||
type AlertSourceUsageCheckFragment struct { | ||
AlertSourceNamePredicate Predicate `graphql:"alertSourceNamePredicate"` | ||
AlertSourceType AlertSourceTypeEnum `graphql:"alertSourceType"` | ||
} | ||
|
||
type CheckAlertSourceUsageCreateInput struct { | ||
CheckCreateInput | ||
|
||
AlertSourceType AlertSourceTypeEnum `json:"alertSourceType,omitempty"` | ||
AlertSourceNamePredicate *PredicateInput `json:"alertSourceNamePredicate,omitempty"` | ||
} | ||
|
||
type CheckAlertSourceUsageUpdateInput struct { | ||
CheckUpdateInput | ||
|
||
AlertSourceType AlertSourceTypeEnum `json:"alertSourceType,omitempty"` | ||
AlertSourceNamePredicate *PredicateUpdateInput `json:"alertSourceNamePredicate,omitempty"` | ||
} | ||
|
||
func (client *Client) CreateCheckAlertSourceUsage(input CheckAlertSourceUsageCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkAlertSourceUsageCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckAlertSourceUsageCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckAlertSourceUsage(input CheckAlertSourceUsageUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkAlertSourceUsageUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckAlertSourceUsageUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package opslevel | ||
|
||
type CustomEventCheckFragment struct { | ||
Integration IntegrationId `graphql:"integration"` | ||
PassPending bool `graphql:"passPending"` | ||
ResultMessage string `graphql:"resultMessage"` | ||
ServiceSelector string `graphql:"serviceSelector"` | ||
SuccessCondition string `graphql:"successCondition"` | ||
} | ||
|
||
type CheckCustomEventCreateInput struct { | ||
CheckCreateInput | ||
|
||
Integration ID `json:"integrationId"` | ||
ServiceSelector string `json:"serviceSelector"` | ||
SuccessCondition string `json:"successCondition"` | ||
Message string `json:"resultMessage,omitempty"` | ||
PassPending *bool `json:"passPending,omitempty"` | ||
} | ||
|
||
type CheckCustomEventUpdateInput struct { | ||
CheckUpdateInput | ||
|
||
ServiceSelector string `json:"serviceSelector,omitempty"` | ||
SuccessCondition string `json:"successCondition,omitempty"` | ||
Message *string `json:"resultMessage,omitempty"` | ||
PassPending *bool `json:"passPending,omitempty"` | ||
Integration *ID `json:"integrationId,omitempty"` | ||
} | ||
|
||
func (client *Client) CreateCheckCustomEvent(input CheckCustomEventCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkCustomEventCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckCustomEventCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckCustomEvent(input CheckCustomEventUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkCustomEventUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckCustomEventUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package opslevel | ||
|
||
type GitBranchProtectionCheckFragment struct{} | ||
|
||
type CheckGitBranchProtectionCreateInput struct { | ||
CheckCreateInput | ||
} | ||
|
||
type CheckGitBranchProtectionUpdateInput struct { | ||
CheckUpdateInput | ||
} | ||
|
||
func (client *Client) CreateCheckGitBranchProtection(input CheckGitBranchProtectionCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkGitBranchProtectionCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckGitBranchProtectionCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckGitBranchProtection(input CheckGitBranchProtectionUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkGitBranchProtectionUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckGitBranchProtectionUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package opslevel | ||
|
||
type HasDocumentationCheckFragment struct { | ||
DocumentType HasDocumentationTypeEnum `graphql:"documentType"` | ||
DocumentSubtype HasDocumentationSubtypeEnum `graphql:"documentSubtype"` | ||
} | ||
|
||
type CheckHasDocumentationCreateInput struct { | ||
CheckCreateInput | ||
|
||
DocumentType HasDocumentationTypeEnum `json:"documentType"` | ||
DocumentSubtype HasDocumentationSubtypeEnum `json:"documentSubtype"` | ||
} | ||
|
||
type CheckHasDocumentationUpdateInput struct { | ||
CheckUpdateInput | ||
|
||
DocumentType HasDocumentationTypeEnum `json:"documentType"` | ||
DocumentSubtype HasDocumentationSubtypeEnum `json:"documentSubtype"` | ||
} | ||
|
||
func (client *Client) CreateCheckHasDocumentation(input CheckHasDocumentationCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkHasDocumentationCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckHasDocumentationCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckHasDocumentation(input CheckHasDocumentationUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkHasDocumentationUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckHasDocumentationUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package opslevel | ||
|
||
type ServiceOwnershipCheckFragment struct { | ||
RequireContactMethod *bool `graphql:"requireContactMethod"` | ||
ContactMethod *ServiceOwnershipCheckContactType `graphql:"contactMethod"` | ||
TeamTagKey string `graphql:"tagKey"` | ||
TeamTagPredicate *Predicate `graphql:"tagPredicate"` | ||
} | ||
|
||
type CheckServiceOwnershipCreateInput struct { | ||
CheckCreateInput | ||
|
||
RequireContactMethod *bool `json:"requireContactMethod,omitempty"` | ||
ContactMethod *ServiceOwnershipCheckContactType `json:"contactMethod,omitempty"` | ||
TeamTagKey string `json:"tagKey,omitempty"` | ||
TeamTagPredicate *PredicateInput `json:"tagPredicate,omitempty"` | ||
} | ||
|
||
type CheckServiceOwnershipUpdateInput struct { | ||
CheckUpdateInput | ||
|
||
RequireContactMethod *bool `json:"requireContactMethod,omitempty"` | ||
ContactMethod *ServiceOwnershipCheckContactType `json:"contactMethod,omitempty"` | ||
TeamTagKey string `json:"tagKey,omitempty"` | ||
TeamTagPredicate *PredicateUpdateInput `json:"tagPredicate,omitempty"` | ||
} | ||
|
||
func (client *Client) CreateCheckServiceOwnership(input CheckServiceOwnershipCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkServiceOwnershipCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckServiceOwnershipCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckServiceOwnership(input CheckServiceOwnershipUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkServiceOwnershipUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckServiceOwnershipUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package opslevel | ||
|
||
type HasRecentDeployCheckFragment struct { | ||
Days int `graphql:"days"` | ||
} | ||
|
||
type CheckHasRecentDeployCreateInput struct { | ||
CheckCreateInput | ||
|
||
Days int `json:"days"` | ||
} | ||
|
||
type CheckHasRecentDeployUpdateInput struct { | ||
CheckUpdateInput | ||
|
||
Days *int `json:"days,omitempty"` | ||
} | ||
|
||
func (client *Client) CreateCheckHasRecentDeploy(input CheckHasRecentDeployCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkHasRecentDeployCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckHasRecentDeployCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckHasRecentDeploy(input CheckHasRecentDeployUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkHasRecentDeployUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckHasRecentDeployUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package opslevel | ||
|
||
type CheckRepositoryIntegratedCreateInput struct { | ||
CheckCreateInput | ||
} | ||
|
||
type CheckRepositoryIntegratedUpdateInput struct { | ||
CheckUpdateInput | ||
} | ||
|
||
func (client *Client) CreateCheckRepositoryIntegrated(input CheckRepositoryIntegratedCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkRepositoryIntegratedCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckRepositoryIntegratedCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckRepositoryIntegrated(input CheckRepositoryIntegratedUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkRepositoryIntegratedUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckRepositoryIntegratedUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package opslevel | ||
|
||
import "github.com/relvacode/iso8601" | ||
|
||
type ManualCheckFragment struct { | ||
UpdateFrequency *ManualCheckFrequency `graphql:"updateFrequency"` | ||
UpdateRequiresComment bool `graphql:"updateRequiresComment"` | ||
} | ||
|
||
type ManualCheckFrequency struct { | ||
StartingDate iso8601.Time `graphql:"startingDate"` | ||
FrequencyTimeScale FrequencyTimeScale `graphql:"frequencyTimeScale"` | ||
FrequencyValue int `graphql:"frequencyValue"` | ||
} | ||
|
||
type ManualCheckFrequencyInput struct { | ||
StartingDate iso8601.Time `json:"startingDate"` | ||
FrequencyTimeScale FrequencyTimeScale `json:"frequencyTimeScale"` | ||
FrequencyValue int `json:"frequencyValue"` | ||
} | ||
|
||
func NewManualCheckFrequencyInput(startingDate string, timeScale FrequencyTimeScale, value int) *ManualCheckFrequencyInput { | ||
return &ManualCheckFrequencyInput{ | ||
StartingDate: NewISO8601Date(startingDate), | ||
FrequencyTimeScale: timeScale, | ||
FrequencyValue: value, | ||
} | ||
} | ||
|
||
type CheckManualCreateInput struct { | ||
CheckCreateInput | ||
|
||
UpdateFrequency *ManualCheckFrequencyInput `json:"updateFrequency,omitempty"` | ||
UpdateRequiresComment bool `json:"updateRequiresComment"` | ||
} | ||
|
||
type CheckManualUpdateInput struct { | ||
CheckUpdateInput | ||
|
||
UpdateFrequency *ManualCheckFrequencyInput `json:"updateFrequency,omitempty"` | ||
UpdateRequiresComment bool `json:"updateRequiresComment,omitempty"` | ||
} | ||
|
||
func (client *Client) CreateCheckManual(input CheckManualCreateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkManualCreate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckManualCreate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} | ||
|
||
func (client *Client) UpdateCheckManual(input CheckManualUpdateInput) (*Check, error) { | ||
var m struct { | ||
Payload CheckResponsePayload `graphql:"checkManualUpdate(input: $input)"` | ||
} | ||
v := PayloadVariables{ | ||
"input": input, | ||
} | ||
err := client.Mutate(&m, v, WithName("CheckManualUpdate")) | ||
return &m.Payload.Check, HandleErrors(err, m.Payload.Errors) | ||
} |
Oops, something went wrong.