Skip to content

Commit

Permalink
Merge pull request #1809 from ansible-semaphore/develop_remove_extrac…
Browse files Browse the repository at this point in the history
…tors

Remove Integration Extractors
  • Loading branch information
fiftin committed Mar 6, 2024
2 parents 3a225af + 3a0b734 commit a176fde
Show file tree
Hide file tree
Showing 28 changed files with 262 additions and 994 deletions.
14 changes: 2 additions & 12 deletions .dredd/hooks/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var task *db.Task
var schedule *db.Schedule
var view *db.View
var integration *db.Integration
var integrationextractor *db.IntegrationExtractor
var integrationextractvalue *db.IntegrationExtractValue
var integrationmatch *db.IntegrationMatcher

Expand All @@ -30,7 +29,6 @@ var inventoryID int
var environmentID int
var templateID int
var integrationID int
var integrationExtractorID int
var integrationExtractValueID int
var integrationMatchID int

Expand All @@ -45,9 +43,8 @@ var capabilities = map[string][]string{
"schedule": {"template"},
"view": {},
"integration": {"project", "template"},
"integrationextractor": {"integration"},
"integrationextractvalue": {"integrationextractor"},
"integrationmatcher": {"integrationextractor"},
"integrationextractvalue": {"integration"},
"integrationmatcher": {"integration"},
}

func capabilityWrapper(cap string) func(t *trans.Transaction) {
Expand Down Expand Up @@ -147,9 +144,6 @@ func resolveCapability(caps []string, resolved []string, uid string) {
case "integration":
integration = addIntegration()
integrationID = integration.ID
case "integrationextractor":
integrationextractor = addIntegrationExtractor()
integrationExtractorID = integrationextractor.ID
case "integrationextractvalue":
integrationextractvalue = addIntegrationExtractValue()
integrationExtractValueID = integrationextractvalue.ID
Expand Down Expand Up @@ -183,7 +177,6 @@ var pathSubPatterns = []func() string{
func() string { return strconv.Itoa(schedule.ID) },
func() string { return strconv.Itoa(view.ID) },
func() string { return strconv.Itoa(integration.ID) },
func() string { return strconv.Itoa(integrationextractor.ID) },
func() string { return strconv.Itoa(integrationextractvalue.ID) },
func() string { return strconv.Itoa(integrationmatch.ID) },
}
Expand Down Expand Up @@ -233,9 +226,6 @@ func alterRequestBody(t *trans.Transaction) {
if integration != nil {
bodyFieldProcessor("integration_id", integration.ID, &request)
}
if integrationextractor != nil {
bodyFieldProcessor("extractor_id", integrationextractor.ID, &request)
}
if integrationextractvalue != nil {
bodyFieldProcessor("value_id", integrationextractvalue.ID, &request)
}
Expand Down
40 changes: 13 additions & 27 deletions .dredd/hooks/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func truncateAll() {
"user",
"project__view",
"project__integration",
"project__integration_extractor",
"project__integration_extract_value",
"project__integration_matcher",
}
Expand Down Expand Up @@ -243,27 +242,14 @@ func addIntegration() *db.Integration {
return &integration
}

func addIntegrationExtractor() *db.IntegrationExtractor {
integrationextractor, err := store.CreateIntegrationExtractor(userProject.ID, db.IntegrationExtractor{
IntegrationID: integrationID,
Name: "Integration Extractor",
})

if err != nil {
panic(err)
}

return &integrationextractor
}

func addIntegrationExtractValue() *db.IntegrationExtractValue {
integrationextractvalue, err := store.CreateIntegrationExtractValue(userProject.ID, db.IntegrationExtractValue{
Name: "Value",
ExtractorID: integrationExtractorID,
ValueSource: db.IntegrationExtractBodyValue,
BodyDataType: db.IntegrationBodyDataJSON,
Key: "key",
Variable: "var",
Name: "Value",
IntegrationID: integrationID,
ValueSource: db.IntegrationExtractBodyValue,
BodyDataType: db.IntegrationBodyDataJSON,
Key: "key",
Variable: "var",
})

if err != nil {
Expand All @@ -275,13 +261,13 @@ func addIntegrationExtractValue() *db.IntegrationExtractValue {

func addIntegrationMatcher() *db.IntegrationMatcher {
integrationmatch, err := store.CreateIntegrationMatcher(userProject.ID, db.IntegrationMatcher{
Name: "matcher",
ExtractorID: integrationExtractorID,
MatchType: "body",
Method: "equals",
BodyDataType: "json",
Key: "key",
Value: "value",
Name: "matcher",
IntegrationID: integrationID,
MatchType: "body",
Method: "equals",
BodyDataType: "json",
Key: "key",
Value: "value",
})

if err != nil {
Expand Down
20 changes: 8 additions & 12 deletions .dredd/hooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,14 @@ func main() {
h.Before("project > /api/project/{project_id}/integrations/{integration_id} > Update Integration > 204 > application/json", capabilityWrapper("integration"))
h.Before("project > /api/project/{project_id}/integrations/{integration_id} > Remove integration > 204 > application/json", capabilityWrapper("integration"))

h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors > Get Integration Extractors > 200 > application/json", capabilityWrapper("integrationextractor"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors > Add Integration Extractor > 201 > application/json", capabilityWrapper("integration"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id} > Updates Integration extractor > 204 > application/json", capabilityWrapper("integrationextractor"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id} > Removes integration extractor > 204 > application/json", capabilityWrapper("integrationextractor"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values > Get Integration Extracted Values linked to integration extractor > 200 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values > Add Integration Extracted Value > 204 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values/{extractvalue_id} > Removes integration extract value > 204 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values > Add Integration Extracted Value > 204 > application/json", capabilityWrapper("integrationextractor"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values/{extractvalue_id} > Updates Integration ExtractValue > 204 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers > Get Integration Matcher linked to integration extractor > 200 > application/json", capabilityWrapper("integrationextractor"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers > Add Integration Matcher > 204 > application/json", capabilityWrapper("integrationextractor"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers/{matcher_id} > Updates Integration Matcher > 204 > application/json", capabilityWrapper("integrationmatcher"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/values > Get Integration Extracted Values linked to integration extractor > 200 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/values > Add Integration Extracted Value > 204 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/values/{extractvalue_id} > Removes integration extract value > 204 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/values > Add Integration Extracted Value > 204 > application/json", capabilityWrapper("integration"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/values/{extractvalue_id} > Updates Integration ExtractValue > 204 > application/json", capabilityWrapper("integrationextractvalue"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers > Get Integration Matcher linked to integration extractor > 200 > application/json", capabilityWrapper("integration"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers > Add Integration Matcher > 204 > application/json", capabilityWrapper("integration"))
h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers/{matcher_id} > Updates Integration Matcher > 204 > application/json", capabilityWrapper("integrationmatcher"))

h.Before("project > /api/project/{project_id}/keys/{key_id} > Updates access key > 204 > application/json", capabilityWrapper("access_key"))
h.Before("project > /api/project/{project_id}/keys/{key_id} > Removes access key > 204 > application/json", capabilityWrapper("access_key"))
Expand Down
112 changes: 10 additions & 102 deletions api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,35 +503,12 @@ definitions:
template_id:
type: integer

IntegrationExtractorRequest:
type: object
properties:
name:
type: string
example: "extractor"
integration_id:
type: integer

IntegrationExtractor:
type: object
properties:
id:
type: integer
name:
type: string
example: "extractor"
integration_id:
type: integer

IntegrationExtractValueRequest:
type: object
properties:
name:
type: string
example: deploy
extractor_id:
type: integer
minimum: 1
value_source:
type: string
enum: [body, header]
Expand All @@ -553,9 +530,6 @@ definitions:
name:
type: string
example: extract this value
extractor_id:
type: integer
minimum: 1
value_source:
type: string
enum: [body, header]
Expand All @@ -568,16 +542,15 @@ definitions:
variable:
type: string
example: variable
integration_id:
type: integer

IntegrationMatcherRequest:
type: object
properties:
name:
type: string
example: deploy
extractor_id:
type: integer
minimum: 1
match_type:
type: string
enum: [body, header]
Expand All @@ -599,12 +572,11 @@ definitions:
properties:
id:
type: integer
integration_id:
type: integer
name:
type: string
example: deploy
extractor_id:
type: integer
minimum: 1
match_type:
type: string
enum: [body, header]
Expand Down Expand Up @@ -963,27 +935,20 @@ parameters:
type: integer
required: true
x-example: 11
extractor_id:
name: extractor_id
description: extractor ID
in: path
type: integer
required: true
x-example: 12
extractvalue_id:
name: extractvalue_id
description: extractValue ID
in: path
type: integer
required: true
x-example: 13
x-example: 12
matcher_id:
name: matcher_id
description: matcher ID
in: path
type: integer
required: true
x-example: 14
x-example: 13

paths:
/ping:
Expand Down Expand Up @@ -1525,64 +1490,10 @@ paths:
responses:
204:
description: integration removed
/project/{project_id}/integrations/{integration_id}/extractors:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/integration_id"
get:
tags:
- integration
summary: Get Integration Extractors
responses:
200:
description: Integration Extractors
schema:
type: array
items:
$ref: "#/definitions/IntegrationExtractor"
post:
tags:
- project
summary: Add Integration Extractor
parameters:
- name: Integration Extractor
in: body
required: true
schema:
$ref: "#/definitions/IntegrationExtractor"
responses:
201:
description: Integration Extractor Created
/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/integration_id"
- $ref: "#/parameters/extractor_id"
put:
tags:
- integration
summary: Updates Integration extractor
parameters:
- name: Integration Extractor
in: body
required: true
schema:
$ref: "#/definitions/IntegrationExtractorRequest"
responses:
204:
description: Integration Extractor updated
delete:
tags:
- integration
summary: Removes integration extractor
responses:
204:
description: integration extractor removed
/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values:
/project/{project_id}/integrations/{integration_id}/values:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/integration_id"
- $ref: "#/parameters/extractor_id"
get:
tags:
- integration
Expand All @@ -1609,11 +1520,10 @@ paths:
description: Integration Extract Value Created
400:
description: Bad Integration Extract Value params
/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values/{extractvalue_id}:
/project/{project_id}/integrations/{integration_id}/values/{extractvalue_id}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/integration_id"
- $ref: "#/parameters/extractor_id"
- $ref: "#/parameters/extractvalue_id"
put:
tags:
Expand All @@ -1637,11 +1547,10 @@ paths:
responses:
204:
description: integration extract value removed
/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers:
/project/{project_id}/integrations/{integration_id}/matchers:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/integration_id"
- $ref: "#/parameters/extractor_id"
get:
tags:
- integration
Expand All @@ -1668,11 +1577,10 @@ paths:
description: Integration Matcher Created
400:
description: Bad Integration Matcher params
/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers/{matcher_id}:
/project/{project_id}/integrations/{integration_id}/matchers/{matcher_id}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/integration_id"
- $ref: "#/parameters/extractor_id"
- $ref: "#/parameters/matcher_id"
put:
tags:
Expand Down
Loading

0 comments on commit a176fde

Please sign in to comment.