diff --git a/.github/workflows/enum-gen.yaml b/.github/workflows/enum-gen.yaml new file mode 100644 index 00000000..cfea249f --- /dev/null +++ b/.github/workflows/enum-gen.yaml @@ -0,0 +1,36 @@ +name: "Enum Gen" + +on: + workflow_dispatch: {} + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Fetch all tags + run: git fetch --force --tags + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + - name: Install Task + uses: arduino/setup-task@v1 + with: + version: 3.x + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Run Tests + run: |- + task setup + task generate + - name: Ensure Changelog + run: | + git config user.name "OpsLevel Bots" + git config user.email "bots@opslevel.com" + git add enum.go + git commit -m "Regenerate enum.go" + git push origin HEAD:bot/enum-gen + gh pr create --title "Regenerate enum.go" --body "Regenerate enum.go" diff --git a/check_has_owner.go b/check_has_owner.go index b16d8d66..a3275c90 100644 --- a/check_has_owner.go +++ b/check_has_owner.go @@ -1,28 +1,28 @@ package opslevel type ServiceOwnershipCheckFragment struct { - RequireContactMethod *bool `graphql:"requireContactMethod"` - ContactMethod *ServiceOwnershipCheckContactType `graphql:"contactMethod"` - TeamTagKey string `graphql:"tagKey"` - TeamTagPredicate *Predicate `graphql:"tagPredicate"` + RequireContactMethod *bool `graphql:"requireContactMethod"` + ContactMethod *ContactType `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"` + RequireContactMethod *bool `json:"requireContactMethod,omitempty"` + ContactMethod *ContactType `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"` + RequireContactMethod *bool `json:"requireContactMethod,omitempty"` + ContactMethod *ContactType `json:"contactMethod,omitempty"` + TeamTagKey string `json:"tagKey,omitempty"` + TeamTagPredicate *PredicateUpdateInput `json:"tagPredicate,omitempty"` } func (client *Client) CreateCheckServiceOwnership(input CheckServiceOwnershipCreateInput) (*Check, error) { diff --git a/check_test.go b/check_test.go index bc92c2aa..cb3f22d0 100644 --- a/check_test.go +++ b/check_test.go @@ -321,7 +321,7 @@ var testcases = map[string]struct { "CreateServiceOwnership": { fixture: "check/create_service_ownership", body: func(c *ol.Client) (*ol.Check, error) { - slackType := ol.ServiceOwnershipCheckContactTypeSlack + slackType := ol.ContactTypeSlack return c.CreateCheckServiceOwnership(ol.CheckServiceOwnershipCreateInput{ CheckCreateInput: checkCreateInput, RequireContactMethod: ol.Bool(true), @@ -337,7 +337,7 @@ var testcases = map[string]struct { "UpdateServiceOwnership": { fixture: "check/update_service_ownership", body: func(c *ol.Client) (*ol.Check, error) { - emailType := ol.ServiceOwnershipCheckContactTypeEmail + emailType := ol.ContactTypeEmail return c.UpdateCheckServiceOwnership(ol.CheckServiceOwnershipUpdateInput{ CheckUpdateInput: checkUpdateInput, RequireContactMethod: ol.Bool(true), diff --git a/clientGQL.go b/clientGQL.go index b706d233..e96fa764 100644 --- a/clientGQL.go +++ b/clientGQL.go @@ -3,10 +3,11 @@ package opslevel import ( "context" "fmt" - "github.com/hashicorp/go-retryablehttp" - "github.com/hasura/go-graphql-client" "net/http" "strings" + + "github.com/hashicorp/go-retryablehttp" + "github.com/hasura/go-graphql-client" ) type Client struct { diff --git a/enum.go b/enum.go index 82d711ed..33228626 100644 --- a/enum.go +++ b/enum.go @@ -298,27 +298,6 @@ var AllContactType = []string{ string(ContactTypeGitHub), } -// TODO: This appears to be duplicative of the above and i'm not sure why we need it -// ContactType represents the method of contact. -type ServiceOwnershipCheckContactType string - -const ( - ServiceOwnershipCheckContactTypeAny ServiceOwnershipCheckContactType = "any" // Any contact method. - ServiceOwnershipCheckContactTypeSlack ServiceOwnershipCheckContactType = "slack" // A Slack channel contact method. - ServiceOwnershipCheckContactTypeSlackHandle ServiceOwnershipCheckContactType = "slack_handle" // A Slack handle contact method. - ServiceOwnershipCheckContactTypeEmail ServiceOwnershipCheckContactType = "email" // An email contact method. - ServiceOwnershipCheckContactTypeWeb ServiceOwnershipCheckContactType = "web" // A website contact method. -) - -// All ServiceOwnershipContactType as []string -var AllServiceOwnershipCheckContactType = []string{ - string(ServiceOwnershipCheckContactTypeAny), - string(ServiceOwnershipCheckContactTypeSlack), - string(ServiceOwnershipCheckContactTypeSlackHandle), - string(ServiceOwnershipCheckContactTypeEmail), - string(ServiceOwnershipCheckContactTypeWeb), -} - // CustomActionsEntityTypeEnum represents the entity types a custom action can be associated with. type CustomActionsEntityTypeEnum string @@ -460,6 +439,7 @@ const ( PredicateKeyEnumTags PredicateKeyEnum = "tags" // Filter by `tags` field. PredicateKeyEnumOwnerID PredicateKeyEnum = "owner_id" // Filter by `owner` field. PredicateKeyEnumGroupIDs PredicateKeyEnum = "group_ids" // Filter by group hierarchy. Will return resources who's owner is in the group ancestry chain. + PredicateKeyEnumOwnerIDs PredicateKeyEnum = "owner_ids" // Filter by `owner` hierarchy. Will return resources who's owner is in the team ancestry chain. PredicateKeyEnumCreationSource PredicateKeyEnum = "creation_source" // Filter by the creation source. PredicateKeyEnumRepositoryIDs PredicateKeyEnum = "repository_ids" // Filter by Repository that this service is attached to, if any. PredicateKeyEnumDomainID PredicateKeyEnum = "domain_id" // Filter by Domain that includes the System this service is assigned to, if any. @@ -478,6 +458,7 @@ var AllPredicateKeyEnum = []string{ string(PredicateKeyEnumTags), string(PredicateKeyEnumOwnerID), string(PredicateKeyEnumGroupIDs), + string(PredicateKeyEnumOwnerIDs), string(PredicateKeyEnumCreationSource), string(PredicateKeyEnumRepositoryIDs), string(PredicateKeyEnumDomainID), @@ -787,14 +768,16 @@ var AllToolCategory = []string{ type UserRole string const ( - UserRoleUser UserRole = "user" // A regular user on the account. - UserRoleAdmin UserRole = "admin" // An administrator on the account. + UserRoleUser UserRole = "user" // A regular user on the account. + UserRoleAdmin UserRole = "admin" // An administrator on the account. + UserRoleBasicUser UserRole = "basic_user" // A basic user on the account with limited access. ) // All UserRole as []string var AllUserRole = []string{ string(UserRoleUser), string(UserRoleAdmin), + string(UserRoleBasicUser), } // UsersFilterEnum represents fields that can be used as part of filter for users. diff --git a/infra_test.go b/infra_test.go index 7f759c08..de55dd86 100644 --- a/infra_test.go +++ b/infra_test.go @@ -250,13 +250,13 @@ func TestGetInfrastructureResourceTags(t *testing.T) { // Arrange requests := []TestRequest{ { - `{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", + Request: `{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", "variables": { {{ template "first_page_variables" }}, "infrastructureResource": {"id": "Z2lkOi8vb3BzbGV2ZWwvUmVwb3NpdG9yaWVzOjpHaXRsYWIvMTA5ODc"} } }`, - `{ + Response: `{ "data": { "account": { "infrastructureResource": { @@ -287,13 +287,13 @@ func TestGetInfrastructureResourceTags(t *testing.T) { }`, }, { - `{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", + Request: `{"query": "query InfrastructureResourceTags($after:String!$first:Int!$infrastructureResource:IdentifierInput!){account{infrastructureResource(input: $infrastructureResource){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", "variables": { {{ template "second_page_variables" }}, "infrastructureResource": {"id": "Z2lkOi8vb3BzbGV2ZWwvUmVwb3NpdG9yaWVzOjpHaXRsYWIvMTA5ODc"} } }`, - `{ + Response: `{ "data": { "account": { "infrastructureResource": { diff --git a/user_test.go b/user_test.go index 63fb7350..5d49690e 100644 --- a/user_test.go +++ b/user_test.go @@ -254,12 +254,12 @@ func TestGetUserTags(t *testing.T) { // Arrange requests := []TestRequest{ { - `{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", + Request: `{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", "variables": { {{ template "first_page_variables" }}, "user": "{{ template "id1"}}" }}`, - `{ + Response: `{ "data": { "account": { "user": { @@ -290,13 +290,13 @@ func TestGetUserTags(t *testing.T) { }`, }, { - `{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", + Request: `{"query": "query UserTagsList($after:String!$first:Int!$user:ID!){account{user(id: $user){tags(after: $after, first: $first){nodes{id,key,value},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}}", "variables": { {{ template "second_page_variables" }}, "user": "{{ template "id1"}}" } }`, - `{ + Response: `{ "data": { "account": { "user": {