Skip to content

Commit

Permalink
Merge pull request #229 from OpsLevel/kr/check-input-refactor
Browse files Browse the repository at this point in the history
refactor check input constructors to make more grokable codebase
  • Loading branch information
rocktavious authored Aug 10, 2023
2 parents 600380b + ecf0992 commit 5ead4cb
Show file tree
Hide file tree
Showing 18 changed files with 862 additions and 658 deletions.
799 changes: 141 additions & 658 deletions check.go

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions check_alert_source_usage.go
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)
}
51 changes: 51 additions & 0 deletions check_custom_event.go
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)
}
33 changes: 33 additions & 0 deletions check_git_branch_protection.go
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)
}
42 changes: 42 additions & 0 deletions check_has_documentation.go
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)
}
48 changes: 48 additions & 0 deletions check_has_owner.go
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)
}
39 changes: 39 additions & 0 deletions check_has_recent_deploy.go
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)
}
31 changes: 31 additions & 0 deletions check_has_repository.go
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)
}
64 changes: 64 additions & 0 deletions check_manual.go
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)
}
Loading

0 comments on commit 5ead4cb

Please sign in to comment.