Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix service catalog schema change #1749

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2022-11-09 16:22:58.929339",
"spec_repo_commit": "a896c6f6"
"regenerated": "2022-11-14 19:04:07.954261",
"spec_repo_commit": "aaa18608"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-11-09 16:22:58.941427",
"spec_repo_commit": "a896c6f6"
"regenerated": "2022-11-14 19:04:07.967183",
"spec_repo_commit": "aaa18608"
}
}
}
8 changes: 4 additions & 4 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9701,12 +9701,12 @@ components:
properties:
region:
$ref: '#/components/schemas/ServiceDefinitionV2OpsgenieRegion'
service-id:
description: Opsgenie service id.
example: 123e4567-e89b-12d3-a456-426614174000
service-url:
description: Opsgenie service url.
example: https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000
type: string
required:
- service-id
- service-url
type: object
ServiceDefinitionV2OpsgenieRegion:
description: Opsgenie instance region.
Expand Down
40 changes: 20 additions & 20 deletions api/datadogV2/model_service_definition_v2_opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
type ServiceDefinitionV2Opsgenie struct {
// Opsgenie instance region.
Region *ServiceDefinitionV2OpsgenieRegion `json:"region,omitempty"`
// Opsgenie service id.
ServiceId string `json:"service-id"`
// Opsgenie service url.
ServiceUrl string `json:"service-url"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{}
Expand All @@ -24,9 +24,9 @@ type ServiceDefinitionV2Opsgenie struct {
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewServiceDefinitionV2Opsgenie(serviceId string) *ServiceDefinitionV2Opsgenie {
func NewServiceDefinitionV2Opsgenie(serviceUrl string) *ServiceDefinitionV2Opsgenie {
this := ServiceDefinitionV2Opsgenie{}
this.ServiceId = serviceId
this.ServiceUrl = serviceUrl
return &this
}

Expand Down Expand Up @@ -66,27 +66,27 @@ func (o *ServiceDefinitionV2Opsgenie) SetRegion(v ServiceDefinitionV2OpsgenieReg
o.Region = &v
}

// GetServiceId returns the ServiceId field value.
func (o *ServiceDefinitionV2Opsgenie) GetServiceId() string {
// GetServiceUrl returns the ServiceUrl field value.
func (o *ServiceDefinitionV2Opsgenie) GetServiceUrl() string {
if o == nil {
var ret string
return ret
}
return o.ServiceId
return o.ServiceUrl
}

// GetServiceIdOk returns a tuple with the ServiceId field value
// GetServiceUrlOk returns a tuple with the ServiceUrl field value
// and a boolean to check if the value has been set.
func (o *ServiceDefinitionV2Opsgenie) GetServiceIdOk() (*string, bool) {
func (o *ServiceDefinitionV2Opsgenie) GetServiceUrlOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.ServiceId, true
return &o.ServiceUrl, true
}

// SetServiceId sets field value.
func (o *ServiceDefinitionV2Opsgenie) SetServiceId(v string) {
o.ServiceId = v
// SetServiceUrl sets field value.
func (o *ServiceDefinitionV2Opsgenie) SetServiceUrl(v string) {
o.ServiceUrl = v
}

// MarshalJSON serializes the struct using spec logic.
Expand All @@ -98,7 +98,7 @@ func (o ServiceDefinitionV2Opsgenie) MarshalJSON() ([]byte, error) {
if o.Region != nil {
toSerialize["region"] = o.Region
}
toSerialize["service-id"] = o.ServiceId
toSerialize["service-url"] = o.ServiceUrl

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -110,18 +110,18 @@ func (o ServiceDefinitionV2Opsgenie) MarshalJSON() ([]byte, error) {
func (o *ServiceDefinitionV2Opsgenie) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
required := struct {
ServiceId *string `json:"service-id"`
ServiceUrl *string `json:"service-url"`
}{}
all := struct {
Region *ServiceDefinitionV2OpsgenieRegion `json:"region,omitempty"`
ServiceId string `json:"service-id"`
Region *ServiceDefinitionV2OpsgenieRegion `json:"region,omitempty"`
ServiceUrl string `json:"service-url"`
}{}
err = json.Unmarshal(bytes, &required)
if err != nil {
return err
}
if required.ServiceId == nil {
return fmt.Errorf("required field service-id missing")
if required.ServiceUrl == nil {
return fmt.Errorf("required field service-url missing")
}
err = json.Unmarshal(bytes, &all)
if err != nil {
Expand All @@ -141,6 +141,6 @@ func (o *ServiceDefinitionV2Opsgenie) UnmarshalJSON(bytes []byte) (err error) {
return nil
}
o.Region = all.Region
o.ServiceId = all.ServiceId
o.ServiceUrl = all.ServiceUrl
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func main() {
},
Integrations: &datadogV2.ServiceDefinitionV2Integrations{
Opsgenie: &datadogV2.ServiceDefinitionV2Opsgenie{
Region: datadogV2.SERVICEDEFINITIONV2OPSGENIEREGION_US.Ptr(),
ServiceId: "123e4567-e89b-12d3-a456-426614174000",
Region: datadogV2.SERVICEDEFINITIONV2OPSGENIEREGION_US.Ptr(),
ServiceUrl: "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000",
},
Pagerduty: datadog.PtrString("https://my-org.pagerduty.com/service-directory/PMyService"),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewServiceDefinitionApi(apiClient)
r, err := api.DeleteServiceDefinition(ctx, "service-Example-Delete_a_single_service_definition_returns_OK_response")
r, err := api.DeleteServiceDefinition(ctx, "service-definition-test")

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceDefinitionApi.DeleteServiceDefinition`: %v\n", err)
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/service-definition/GetServiceDefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewServiceDefinitionApi(apiClient)
resp, r, err := api.GetServiceDefinition(ctx, "service-Example-Get_a_single_service_definition_returns_OK_response")
resp, r, err := api.GetServiceDefinition(ctx, "service-definition-test")

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ServiceDefinitionApi.GetServiceDefinition`: %v\n", err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-10-11T16:11:15.904Z
2022-11-10T21:14:44.544Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"contacts":[{"contact":"contact@datadoghq.com","name":"Team Email","type":"email"}],"dd-service":"service-Test-Create_or_update_service_definition_returns_CREATED_response-1665504675","dd-team":"my-team","docs":[{"name":"Architecture","provider":"google drive","url":"https://gdrive/mydoc"}],"extensions":{"myorgextension":"extensionvalue"},"integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"}],"repos":[{"name":"Source Code","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"schema-version":"v2","tags":["my:tag","service:tag"],"team":"my-team"}
{"contacts":[{"contact":"contact@datadoghq.com","name":"Team Email","type":"email"}],"dd-service":"service-Test-Create_or_update_service_definition_returns_CREATED_response-1668114884","dd-team":"my-team","docs":[{"name":"Architecture","provider":"google drive","url":"https://gdrive/mydoc"}],"extensions":{"myorgextension":"extensionvalue"},"integrations":{"opsgenie":{"region":"US","service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"}],"repos":[{"name":"Source Code","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"schema-version":"v2","tags":["my:tag","service:tag"],"team":"my-team"}
form: {}
headers:
Accept:
Expand All @@ -11,10 +11,10 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/services/definitions
response:
body: '{"data":[{"attributes":{"meta":{"ingested-schema-version":"v2","ingestion-source":"api","last-modified-time":"2022-10-11T16:11:16.302119241Z","github-html-url":"","warnings":[]},"schema":{"links":[{"url":"https://my-runbook","type":"runbook","name":"Runbook"}],"contacts":[{"contact":"contact@datadoghq.com","type":"email","name":"Team
Email"}],"docs":[{"url":"https://gdrive/mydoc","name":"Architecture","provider":"google
drive"}],"repos":[{"url":"https://github.com/DataDog/schema","name":"Source
Code","provider":"GitHub"}],"tags":["my:tag","service:tag"],"dd-team":"my-team","integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"schema-version":"v2","team":"my-team","extensions":{},"dd-service":"service-test-create_or_update_service_definition_returns_created_response-1665504675"}},"type":"service-definition"}]}
body: '{"data":[{"type":"service-definition","attributes":{"meta":{"last-modified-time":"2022-11-10T21:14:45.52228008Z","github-html-url":"","ingestion-source":"api","warnings":[],"ingested-schema-version":"v2"},"schema":{"schema-version":"v2","dd-service":"service-test-create_or_update_service_definition_returns_created_response-1668114884","dd-team":"my-team","team":"my-team","contacts":[{"name":"Team
Email","type":"email","contact":"contact@datadoghq.com"}],"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"}],"repos":[{"name":"Source
Code","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"docs":[{"name":"Architecture","provider":"google
drive","url":"https://gdrive/mydoc"}],"tags":["my:tag","service:tag"],"integrations":{"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService","opsgenie":{"service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000","region":"US"}},"extensions":{"myorgextension":"extensionvalue"}}}}]}

'
code: 200
Expand All @@ -30,7 +30,7 @@ interactions:
Accept:
- '*/*'
method: DELETE
url: https://api.datadoghq.com/api/v2/services/definitions/service-test-create_or_update_service_definition_returns_created_response-1665504675
url: https://api.datadoghq.com/api/v2/services/definitions/service-test-create_or_update_service_definition_returns_created_response-1668114884
response:
body: '{"errors":["Not Found"],"error_details":[{}]}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-10-10T12:48:37.381Z
2022-11-14T18:19:52.943Z
Original file line number Diff line number Diff line change
@@ -1,56 +1,18 @@
interactions:
- request:
body: |
{"dd-service":"service-Test-Delete_a_single_service_definition_returns_OK_response-1665406117","dd-team":"my-team","docs":[{"name":"Architecture","provider":"google drive","url":"https://gdrive/mygivedoc"}],"extensions":{"frogextension":"extensionfrogvalue"},"integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"}],"repos":[{"name":"Source Code","provider":"GitHub","url":"https://github.com/DataDog/given"}],"schema-version":"v2","tags":["this:tag","service:tag"],"team":"super-team"}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
method: POST
url: https://api.datadoghq.com/api/v2/services/definitions
response:
body: '{"data":[{"attributes":{"meta":{"ingested-schema-version":"v2","ingestion-source":"api","last-modified-time":"2022-10-10T12:48:37.797458518Z","github-html-url":"","warnings":[]},"schema":{"links":[{"url":"https://my-runbook","type":"runbook","name":"Runbook"}],"contacts":[],"docs":[{"url":"https://gdrive/mygivedoc","name":"Architecture","provider":"google
drive"}],"repos":[{"url":"https://github.com/DataDog/given","name":"Source Code","provider":"GitHub"}],"tags":["service:tag","this:tag"],"dd-team":"my-team","integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"schema-version":"v2","team":"super-team","extensions":{},"dd-service":"service-test-delete_a_single_service_definition_returns_ok_response-1665406117"}},"type":"service-definition"}]}

'
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 200 OK
- request:
body: ''
form: {}
headers:
Accept:
- '*/*'
method: DELETE
url: https://api.datadoghq.com/api/v2/services/definitions/service-Test-Delete_a_single_service_definition_returns_OK_response-1665406117
url: https://api.datadoghq.com/api/v2/services/definitions/service-definition-test
response:
body: ''
code: 204
duration: ''
headers: {}
status: 204 No Content
- request:
body: ''
form: {}
headers:
Accept:
- '*/*'
method: DELETE
url: https://api.datadoghq.com/api/v2/services/definitions/service-test-delete_a_single_service_definition_returns_ok_response-1665406117
response:
body: '{"errors":["Not Found"],"error_details":[{}]}

'
code: 404
duration: ''
headers:
Content-Type:
- application/json
status: 404 Not Found
- text/html; charset=utf-8
status: 204 No Content
version: 1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-10-10T12:33:59.012Z
2022-11-14T18:09:34.511Z
Original file line number Diff line number Diff line change
@@ -1,59 +1,23 @@
interactions:
- request:
body: |
{"dd-service":"service-Test-Get_a_single_service_definition_returns_OK_response-1665405239","dd-team":"my-team","docs":[{"name":"Architecture","provider":"google drive","url":"https://gdrive/mygivedoc"}],"extensions":{"frogextension":"extensionfrogvalue"},"integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"}],"repos":[{"name":"Source Code","provider":"GitHub","url":"https://github.com/DataDog/given"}],"schema-version":"v2","tags":["this:tag","service:tag"],"team":"super-team"}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
method: POST
url: https://api.datadoghq.com/api/v2/services/definitions
response:
body: '{"data":[{"attributes":{"meta":{"ingested-schema-version":"v2","ingestion-source":"api","last-modified-time":"2022-10-10T12:33:59.412229035Z","github-html-url":"","warnings":[]},"schema":{"links":[{"url":"https://my-runbook","type":"runbook","name":"Runbook"}],"contacts":[],"docs":[{"url":"https://gdrive/mygivedoc","name":"Architecture","provider":"google
drive"}],"repos":[{"url":"https://github.com/DataDog/given","name":"Source Code","provider":"GitHub"}],"tags":["service:tag","this:tag"],"dd-team":"my-team","integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"schema-version":"v2","team":"super-team","extensions":{},"dd-service":"service-test-get_a_single_service_definition_returns_ok_response-1665405239"}},"type":"service-definition"}]}

'
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 200 OK
- request:
body: ''
form: {}
headers:
Accept:
- application/json
method: GET
url: https://api.datadoghq.com/api/v2/services/definitions/service-Test-Get_a_single_service_definition_returns_OK_response-1665405239
response:
body: '{"data":{"attributes":{"meta":{"ingested-schema-version":"v2","ingestion-source":"api","last-modified-time":"2022-10-10T12:24:16Z","github-html-url":"","warnings":[]},"schema":{"links":[{"url":"https://my-runbook","type":"runbook","name":"Runbook"}],"contacts":[],"docs":[{"url":"https://gdrive/mygivedoc","name":"Architecture","provider":"google
drive"}],"repos":[{"url":"https://github.com/DataDog/given","name":"Source Code","provider":"GitHub"}],"tags":["service:tag","this:tag"],"dd-team":"my-team","integrations":{"opsgenie":{"region":"US","service-id":"123e4567-e89b-12d3-a456-426614174000"},"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService"},"schema-version":"v2","team":"super-team","extensions":{},"dd-service":"service-test-get_a_single_service_definition_returns_ok_response-1665405239"}},"type":"service-definition","id":"d6822c235d26b96b47ded1a3eecba6c1"}}'
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 200 Not Found
- request:
body: ''
form: {}
headers:
Accept:
- '*/*'
method: DELETE
url: https://api.datadoghq.com/api/v2/services/definitions/service-test-get_a_single_service_definition_returns_ok_response-1665405239
url: https://api.datadoghq.com/api/v2/services/definitions/service-definition-test
response:
body: '{"errors":["Not Found"],"error_details":[{}]}
body: '{"data":{"type":"service-definition","id":"77ae46b484fcfd92dc568170b1c534fe","attributes":{"meta":{"last-modified-time":"2022-11-14T18:03:35Z","github-html-url":"","ingestion-source":"api","warnings":[],"ingested-schema-version":"v2"},"schema":{"schema-version":"v2","dd-service":"service-definition-test","dd-team":"my-team","team":"super-team","contacts":[{"name":"Team
Email","type":"email","contact":"contact@datadoghq.com"}],"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"}],"repos":[{"name":"Source
Code","provider":"GitHub","url":"https://github.com/DataDog/schema"}],"docs":[{"name":"Architecture","provider":"google
drive","url":"https://gdrive/mydoc"}],"tags":["service:tag","my:tag"],"integrations":{"pagerduty":"https://my-org.pagerduty.com/service-directory/PMyService","opsgenie":{"service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000","region":"US"}},"extensions":{"myorgextension":"extensionvalue"}}}}}

'
code: 404
code: 200
duration: ''
headers:
Content-Type:
- application/json
status: 404 Not Found
status: 200 OK
version: 1
Loading