Skip to content

Commit

Permalink
Merge pull request #400 from reubenmiller/feat-software-add-type
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller authored Jun 24, 2024
2 parents c904752 + 1d5dcb3 commit 760bed0
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 18 deletions.
32 changes: 27 additions & 5 deletions api/spec/json/software.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
},
{
"description": "Get a list of software packages starting with \"python3\"",
"command": "c8y software list --name \"python3*\"",
"command": "c8y software list --name \"python3*\" --softwareType apt",
"skipTest": true
},
{
"description": "List all software packages of a given software type",
"command": "c8y software list --softwareType rpm",
"skipTest": true
}
]
Expand Down Expand Up @@ -85,6 +90,12 @@
"description": "Filter by deviceType",
"format": "(c8y_Filter.type eq '%s')"
},
{
"name": "softwareType",
"type": "string",
"description": "Filter by softwareType",
"format": "(softwareType eq '%s')"
},
{
"name": "description",
"type": "string",
Expand Down Expand Up @@ -147,15 +158,15 @@
"go": [
{
"description": "Create a software package",
"command": "c8y software create --name \"python3-requests\" --description \"python requests library\""
"command": "c8y software create --name \"python3-requests\" --description \"python requests library\" --softwareType apt"
},
{
"description": "Create a software package which is only applicable for a specific device type",
"command": "c8y software create --name \"python3-requests\" --description \"python requests library\" --deviceType \"c8y_Linux\""
"command": "c8y software create --name \"python3-requests\" --description \"python requests library\" --deviceType \"c8y_Linux\" --softwareType apt"
},
{
"description": "Create the same software package for multiple device types",
"command": "echo -e \"c8y_Linux\\nc8y_MacOS\" | c8y software create --name \"python3-requests\" --description \"python requests library\"",
"command": "echo -e \"c8y_Linux\\nc8y_MacOS\" | c8y software create --name \"python3-requests\" --description \"python requests library\" --softwareType rpm",
"assertStdOut": {
"line-count": 2,
"json": {
Expand All @@ -166,7 +177,8 @@
"..1.method": "POST",
"..1.body.name": "python3-requests",
"..1.body.description": "python requests library",
"..1.body.c8y_Filter.type": "c8y_MacOS"
"..1.body.c8y_Filter.type": "c8y_MacOS",
"..1.body.softwareType": "rpm"
}
}
},
Expand Down Expand Up @@ -199,6 +211,11 @@
"required": false,
"description": "Description of the software package"
},
{
"name": "softwareType",
"type": "string",
"description": "Software type"
},
{
"name": "deviceType",
"type": "string",
Expand Down Expand Up @@ -363,6 +380,11 @@
"required": false,
"description": "Description of the software package"
},
{
"name": "softwareType",
"type": "string",
"description": "Software type"
},
{
"name": "deviceType",
"type": "string",
Expand Down
28 changes: 23 additions & 5 deletions api/spec/yaml/software.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ commands:
skipTest: true

- description: Get a list of software packages starting with "python3"
command: c8y software list --name "python3*"
command: c8y software list --name "python3*" --softwareType apt
skipTest: true

- description: List all software packages of a given software type
command: c8y software list --softwareType rpm
skipTest: true

queryParameters:
Expand Down Expand Up @@ -70,6 +74,11 @@ commands:
description: Filter by deviceType
format: (c8y_Filter.type eq '%s')

- name: softwareType
type: string
description: Filter by softwareType
format: (softwareType eq '%s')

- name: description
type: string
description: Filter by description
Expand Down Expand Up @@ -115,13 +124,13 @@ commands:

go:
- description: Create a software package
command: c8y software create --name "python3-requests" --description "python requests library"
command: c8y software create --name "python3-requests" --description "python requests library" --softwareType apt

- description: Create a software package which is only applicable for a specific device type
command: c8y software create --name "python3-requests" --description "python requests library" --deviceType "c8y_Linux"
command: c8y software create --name "python3-requests" --description "python requests library" --deviceType "c8y_Linux" --softwareType apt

- description: Create the same software package for multiple device types
command: echo -e "c8y_Linux\nc8y_MacOS" | c8y software create --name "python3-requests" --description "python requests library"
command: echo -e "c8y_Linux\nc8y_MacOS" | c8y software create --name "python3-requests" --description "python requests library" --softwareType rpm
assertStdOut:
line-count: 2
json:
Expand All @@ -133,6 +142,7 @@ commands:
..1.body.name: python3-requests
..1.body.description: python requests library
..1.body.c8y_Filter.type: c8y_MacOS
..1.body.softwareType: rpm

- description: Create a software package and create a new version
skipTest: true
Expand All @@ -154,6 +164,10 @@ commands:
required: false
description: Description of the software package

- name: softwareType
type: string
description: Software type

- name: deviceType
type: string
property: c8y_Filter.type
Expand Down Expand Up @@ -273,7 +287,11 @@ commands:
type: string
required: false
description: Description of the software package


- name: softwareType
type: string
description: Software type

- name: deviceType
type: string
property: c8y_Filter.type
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/software/create/create.auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pkg/cmd/software/list/list.auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/cmd/software/update/update.auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions tests/auto/software/tests/software_create.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
tests:
software_create_Create a software package:
command: c8y software create --name "python3-requests" --description "python requests library"
command: c8y software create --name "python3-requests" --description "python requests library" --softwareType apt
exit-code: 0
stdout:
json:
body.description: python requests library
body.name: python3-requests
body.softwareType: apt
method: POST
path: /inventory/managedObjects
software_create_Create a software package and create a new version:
Expand All @@ -19,17 +20,18 @@ tests:
method: POST
path: /inventory/managedObjects
software_create_Create a software package which is only applicable for a specific device type:
command: c8y software create --name "python3-requests" --description "python requests library" --deviceType "c8y_Linux"
command: c8y software create --name "python3-requests" --description "python requests library" --deviceType "c8y_Linux" --softwareType apt
exit-code: 0
stdout:
json:
body.c8y_Filter.type: c8y_Linux
body.description: python requests library
body.name: python3-requests
body.softwareType: apt
method: POST
path: /inventory/managedObjects
software_create_Create the same software package for multiple device types:
command: $TEST_SHELL -c 'echo -e "c8y_Linux\nc8y_MacOS" | c8y software create --name "python3-requests" --description "python requests library"'
command: $TEST_SHELL -c 'echo -e "c8y_Linux\nc8y_MacOS" | c8y software create --name "python3-requests" --description "python requests library" --softwareType rpm'
exit-code: 0
stdout:
json:
Expand All @@ -40,8 +42,10 @@ tests:
..1.body.c8y_Filter.type: c8y_MacOS
..1.body.description: python requests library
..1.body.name: python3-requests
..1.body.softwareType: rpm
..1.method: POST
body.description: python requests library
body.name: python3-requests
body.softwareType: rpm
method: POST
path: /inventory/managedObjects
13 changes: 12 additions & 1 deletion tests/auto/software/tests/software_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tests:
method: GET
path: /inventory/managedObjects
software_list_Get a list of software packages starting with "python3":
command: c8y software list --name "python3*"
command: c8y software list --name "python3*" --softwareType apt
exit-code: 0
skip: true
stdout:
Expand All @@ -17,3 +17,14 @@ tests:
path: /inventory/managedObjects
contains:
- name=python3*
- softwareType=apt
software_list_List all software packages of a given software type:
command: c8y software list --softwareType rpm
exit-code: 0
skip: true
stdout:
json:
method: GET
path: /inventory/managedObjects
contains:
- softwareType=rpm
5 changes: 5 additions & 0 deletions tools/PSc8y/Public/Get-SoftwareCollection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Get a list of software packages
[string]
$DeviceType,

# Filter by softwareType
[Parameter()]
[string]
$SoftwareType,

# Filter by description
[Parameter()]
[string]
Expand Down
5 changes: 5 additions & 0 deletions tools/PSc8y/Public/New-Software.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Create a software package
[string]
$Description,

# Software type
[Parameter()]
[string]
$SoftwareType,

# Device type filter. Only allow software to be applied to devices of this type
[Parameter(ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
Expand Down
5 changes: 5 additions & 0 deletions tools/PSc8y/Public/Update-Software.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ Update a software package (using pipeline)
[string]
$Description,

# Software type
[Parameter()]
[string]
$SoftwareType,

# Device type filter. Only allow software to be applied to devices of this type
[Parameter()]
[string]
Expand Down

0 comments on commit 760bed0

Please sign in to comment.