Skip to content

Commit

Permalink
Objects WIP pt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
rocktavious committed Jan 28, 2025
1 parent e0cb690 commit 7b36271
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 109 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Refactor-20250127-133514.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Refactor
body: 'BREAKING CHANGE: struct ''OpsLevelWarnings'' was renamed to ''Warning'''
time: 2025-01-27T13:35:14.183763-06:00
4 changes: 0 additions & 4 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ func (pv *PayloadVariables) WithoutDeactivedUsers() *PayloadVariables {
return pv
}

type OpsLevelWarnings struct {
Message string
}

func NullString() *string {
var output *string
return output
Expand Down
6 changes: 3 additions & 3 deletions document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func TestServiceApiDocSettingsUpdate(t *testing.T) {
// Arrange
testRequest := autopilot.NewTestRequest(
`mutation ServiceApiDocSettingsUpdate($docPath:String$docSource:ApiDocumentSourceEnum$service:IdentifierInput!){serviceApiDocSettingsUpdate(service: $service, apiDocumentPath: $docPath, preferredApiDocumentSource: $docSource){service{apiDocumentPath,description,framework,htmlUrl,id,aliases,language,lifecycle{alias,description,id,index,name},locked,managedAliases,name,note,owner{alias,id},parent{id,aliases},preferredApiDocument{id,htmlUrl,source{... on ApiDocIntegration{id,name,type},... on ServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},timestamps{createdAt,updatedAt}},preferredApiDocumentSource,product,repos{edges{node{id,defaultAlias},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},defaultServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},timestamps{createdAt,updatedAt},tools{nodes{category,categoryAlias,displayName,environment,id,url,service{id,aliases}},{{ template "pagination_request" }},totalCount}},errors{message,path}}}`,
`mutation ServiceApiDocSettingsUpdate($docPath:String$docSource:ApiDocumentSourceEnum$service:IdentifierInput!){serviceApiDocSettingsUpdate(service: $service, apiDocumentPath: $docPath, preferredApiDocumentSource: $docSource){service{apiDocumentPath,description,framework,htmlUrl,id,aliases,language,lifecycle{alias,description,id,index,name},locked,managedAliases,name,note,owner{alias,id},parent{id,aliases},preferredApiDocument{id,htmlUrl,source{... on ApiDocIntegration{id,name,type},... on ServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},timestamps{createdAt,updatedAt}},preferredApiDocumentSource,product,repos{edges{node{id,defaultAlias},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},defaultServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},timestamps{createdAt,updatedAt},tools{nodes{category,categoryAlias,displayName,environment,id,service{id,aliases},url},{{ template "pagination_request" }},totalCount}},errors{message,path}}}`,
`{"docPath":"/src/swagger.json", "docSource":"PULL", "service": {"alias":"service_alias" }}`,
`{"data": {"serviceApiDocSettingsUpdate": {"service": {{ template "service_1" }}, "errors": [] }}}`,
)
Expand All @@ -30,7 +30,7 @@ func TestServiceApiDocSettingsUpdate(t *testing.T) {
func TestServiceApiDocSettingsUpdateDocSourceNull(t *testing.T) {
// Arrange
testRequest := autopilot.NewTestRequest(
`mutation ServiceApiDocSettingsUpdate($docPath:String$docSource:ApiDocumentSourceEnum$service:IdentifierInput!){serviceApiDocSettingsUpdate(service: $service, apiDocumentPath: $docPath, preferredApiDocumentSource: $docSource){service{apiDocumentPath,description,framework,htmlUrl,id,aliases,language,lifecycle{alias,description,id,index,name},locked,managedAliases,name,note,owner{alias,id},parent{id,aliases},preferredApiDocument{id,htmlUrl,source{... on ApiDocIntegration{id,name,type},... on ServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},timestamps{createdAt,updatedAt}},preferredApiDocumentSource,product,repos{edges{node{id,defaultAlias},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},defaultServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},timestamps{createdAt,updatedAt},tools{nodes{category,categoryAlias,displayName,environment,id,url,service{id,aliases}},{{ template "pagination_request" }},totalCount}},errors{message,path}}}`,
`mutation ServiceApiDocSettingsUpdate($docPath:String$docSource:ApiDocumentSourceEnum$service:IdentifierInput!){serviceApiDocSettingsUpdate(service: $service, apiDocumentPath: $docPath, preferredApiDocumentSource: $docSource){service{apiDocumentPath,description,framework,htmlUrl,id,aliases,language,lifecycle{alias,description,id,index,name},locked,managedAliases,name,note,owner{alias,id},parent{id,aliases},preferredApiDocument{id,htmlUrl,source{... on ApiDocIntegration{id,name,type},... on ServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},timestamps{createdAt,updatedAt}},preferredApiDocumentSource,product,repos{edges{node{id,defaultAlias},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},defaultServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},timestamps{createdAt,updatedAt},tools{nodes{category,categoryAlias,displayName,environment,id,service{id,aliases},url},{{ template "pagination_request" }},totalCount}},errors{message,path}}}`,
`{"docPath":"/src/swagger.json", "docSource": null, "service": {"alias":"service_alias" }}`,
`{"data": { "serviceApiDocSettingsUpdate": { "service": {{ template "service_1" }}, "errors": [] }}}`,
)
Expand All @@ -48,7 +48,7 @@ func TestServiceApiDocSettingsUpdateDocSourceNull(t *testing.T) {
func TestServiceApiDocSettingsUpdateDocPathNull(t *testing.T) {
// Arrange
testRequest := autopilot.NewTestRequest(
`mutation ServiceApiDocSettingsUpdate($docPath:String$docSource:ApiDocumentSourceEnum$service:IdentifierInput!){serviceApiDocSettingsUpdate(service: $service, apiDocumentPath: $docPath, preferredApiDocumentSource: $docSource){service{apiDocumentPath,description,framework,htmlUrl,id,aliases,language,lifecycle{alias,description,id,index,name},locked,managedAliases,name,note,owner{alias,id},parent{id,aliases},preferredApiDocument{id,htmlUrl,source{... on ApiDocIntegration{id,name,type},... on ServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},timestamps{createdAt,updatedAt}},preferredApiDocumentSource,product,repos{edges{node{id,defaultAlias},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},defaultServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},timestamps{createdAt,updatedAt},tools{nodes{category,categoryAlias,displayName,environment,id,url,service{id,aliases}},{{ template "pagination_request" }},totalCount}},errors{message,path}}}`,
`mutation ServiceApiDocSettingsUpdate($docPath:String$docSource:ApiDocumentSourceEnum$service:IdentifierInput!){serviceApiDocSettingsUpdate(service: $service, apiDocumentPath: $docPath, preferredApiDocumentSource: $docSource){service{apiDocumentPath,description,framework,htmlUrl,id,aliases,language,lifecycle{alias,description,id,index,name},locked,managedAliases,name,note,owner{alias,id},parent{id,aliases},preferredApiDocument{id,htmlUrl,source{... on ApiDocIntegration{id,name,type},... on ServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},timestamps{createdAt,updatedAt}},preferredApiDocumentSource,product,repos{edges{node{id,defaultAlias},serviceRepositories{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}}},{{ template "pagination_request" }},totalCount},defaultServiceRepository{baseDirectory,displayName,id,repository{id,defaultAlias},service{id,aliases}},tags{nodes{id,key,value},{{ template "pagination_request" }},totalCount},tier{alias,description,id,index,name},timestamps{createdAt,updatedAt},tools{nodes{category,categoryAlias,displayName,environment,id,service{id,aliases},url},{{ template "pagination_request" }},totalCount}},errors{message,path}}}`,
`{"docPath":null, "docSource":"PULL", "service": {"alias":"service_alias" }}`,
`{"data": { "serviceApiDocSettingsUpdate": { "service": {{ template "service_1" }}, "errors": [] }}}`,
)
Expand Down
4 changes: 2 additions & 2 deletions infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (client *Client) CreateInfrastructure(input InfraInput) (*InfrastructureRes
var m struct {
Payload struct {
InfrastructureResource InfrastructureResource
Warnings []OpsLevelWarnings // TODO: handle warnings somehow
Warnings []Warning // TODO: handle warnings somehow
Errors []Error
} `graphql:"infrastructureResourceCreate(input: $input)"`
}
Expand Down Expand Up @@ -243,7 +243,7 @@ func (client *Client) UpdateInfrastructure(identifier string, input InfraInput)
var m struct {
Payload struct {
InfrastructureResource InfrastructureResource
Warnings []OpsLevelWarnings // TODO: handle warnings somehow
Warnings []Warning // TODO: handle warnings somehow
Errors []Error
} `graphql:"infrastructureResourceUpdate(infrastructureResource: $identifier, input: $input)"`
}
Expand Down
65 changes: 32 additions & 33 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,46 +423,45 @@ type TeamMembership struct {
User UserId // User for the membership (Required)
}

//// Tier A tier measures how critical or important a service is to your business
//type Tier struct {
// Alias string // The human-friendly, unique identifier for the tier (Optional)
// Description string // A brief description of the tier (Optional)
// Id ID // The unique identifier for the tier (Required)
// Index int // The numerical representation of the tier (Optional)
// Name string // The display name of the tier (Optional)
//}
// Tier A tier measures how critical or important a service is to your business
type Tier struct {
Alias string // The human-friendly, unique identifier for the tier (Optional)
Description string // A brief description of the tier (Optional)
Id ID // The unique identifier for the tier (Required)
Index int // The numerical representation of the tier (Optional)
Name string // The display name of the tier (Optional)
}

// Timestamps Relevant timestamps
type Timestamps struct {
CreatedAt iso8601.Time // The time at which the entity was created (Required)
UpdatedAt iso8601.Time // The time at which the entity was most recently updated (Required)
}

//
//// Tool A tool is used to support the operations of a service
//type Tool struct {
// Category ToolCategory // The category that the tool belongs to (Optional)
// CategoryAlias string // The human-friendly, unique identifier for the tool's category (Optional)
// DisplayName string // The display name of the tool (Optional)
// Environment string // The environment that the tool belongs to (Optional)
// Id ID // The unique identifier for the tool (Required)
// Service ServiceId // The service that is associated to the tool (Required)
// Url string // The URL of the tool (Required)
//}
//
//// UserId A user is someone who belongs to an organization
//type UserId struct {
// Id ID // The unique identifier for the user.
// Email string // The user's email.
//}
//
//// User A user is someone who belongs to an organization
//type User struct {
// UserId
// HtmlUrl string // A link to the HTML page for the resource. Ex. https://app.opslevel.com/services/shopping_cart (Required)
// Name string // The user's full name (Required)
// Role UserRole // The user's assigned role (Optional)
//}
// Tool A tool is used to support the operations of a service
type Tool struct {
Category ToolCategory // The category that the tool belongs to (Optional)
CategoryAlias string // The human-friendly, unique identifier for the tool's category (Optional)
DisplayName string // The display name of the tool (Optional)
Environment string // The environment that the tool belongs to (Optional)
Id ID // The unique identifier for the tool (Required)
Service ServiceId // The service that is associated to the tool (Required)
Url string // The URL of the tool (Required)
}

// UserId A user is someone who belongs to an organization
type UserId struct {
Id ID // The unique identifier for the user.
Email string // The user's email.
}

// User A user is someone who belongs to an organization
type User struct {
UserId
HtmlUrl string // A link to the HTML page for the resource. Ex. https://app.opslevel.com/services/shopping_cart (Required)
Name string // The user's full name (Required)
Role UserRole // The user's assigned role (Optional)
}

// Warning The warnings of the mutation
type Warning struct {
Expand Down
Loading

0 comments on commit 7b36271

Please sign in to comment.