Skip to content

Commit c45109b

Browse files
committed
feat: query for manual update via base image from a collection
[<35;92;38M35;102;41M35;104;41M35;106;41M35;107;4 Signed-off-by: Damiano Mason <damiano.mason@secomind.com>
1 parent 4ccb2cd commit c45109b

3 files changed

Lines changed: 54 additions & 7 deletions

File tree

backend/lib/edgehog/os_management/os_management.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ defmodule Edgehog.OSManagement do
3131
root_level_errors? true
3232

3333
mutations do
34-
create OTAOperation, :create_manual_ota_operation, :manual do
34+
create OTAOperation, :create_manual_ota_operation_no_existing_base_image, :manual do
35+
relay_id_translations input: [device_id: :device]
36+
end
37+
38+
create OTAOperation,
39+
:create_manual_ota_operation_existing_base_image,
40+
:manual_from_collection do
3541
relay_id_translations input: [device_id: :device]
3642
end
3743

backend/lib/edgehog/os_management/ota_operation/ota_operation.ex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ defmodule Edgehog.OSManagement.OTAOperation do
9696
change Changes.SendUpdateRequest
9797
end
9898

99+
create :manual_from_collection do
100+
description "Initiates an OTA update by selecting one from an available collection"
101+
102+
accept [:base_image_url]
103+
104+
argument :device_id, :id do
105+
description "The ID identifying the Device the OTA Operation will be sent to"
106+
end
107+
108+
change manage_relationship(:device_id, :device,
109+
type: :append,
110+
eager_validate_with: Edgehog.Devices
111+
)
112+
113+
change set_attribute(:manual?, true)
114+
115+
change Changes.SendUpdateRequest
116+
end
117+
99118
destroy :destroy do
100119
require_atomic? false
101120

frontend/src/api/schema.graphql

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5005,16 +5005,33 @@ type Tag {
50055005
name: String!
50065006
}
50075007

5008-
"The result of the :create_manual_ota_operation mutation"
5009-
type CreateManualOtaOperationResult {
5008+
"The result of the :create_manual_ota_operation_existing_base_image mutation"
5009+
type CreateManualOtaOperationExistingBaseImageResult {
50105010
"The successful result of the mutation"
50115011
result: OtaOperation
50125012

50135013
"Any errors generated, if the mutation failed"
50145014
errors: [MutationError!]!
50155015
}
50165016

5017-
input CreateManualOtaOperationInput {
5017+
input CreateManualOtaOperationExistingBaseImageInput {
5018+
"The URL of the base image being installed on the device"
5019+
baseImageUrl: String!
5020+
5021+
"The ID identifying the Device the OTA Operation will be sent to"
5022+
deviceId: ID
5023+
}
5024+
5025+
"The result of the :create_manual_ota_operation_no_existing_base_image mutation"
5026+
type CreateManualOtaOperationNoExistingBaseImageResult {
5027+
"The successful result of the mutation"
5028+
result: OtaOperation
5029+
5030+
"Any errors generated, if the mutation failed"
5031+
errors: [MutationError!]!
5032+
}
5033+
5034+
input CreateManualOtaOperationNoExistingBaseImageInput {
50185035
"The ID identifying the Device the OTA Operation will be sent to"
50195036
deviceId: ID!
50205037

@@ -6257,9 +6274,14 @@ type RootMutationType {
62576274
deleteChannel(id: ID!): DeleteChannelResult
62586275

62596276
"Initiates an OTA update with a user provided OS image"
6260-
createManualOtaOperation(
6261-
input: CreateManualOtaOperationInput!
6262-
): CreateManualOtaOperationResult
6277+
createManualOtaOperationNoExistingBaseImage(
6278+
input: CreateManualOtaOperationNoExistingBaseImageInput!
6279+
): CreateManualOtaOperationNoExistingBaseImageResult
6280+
6281+
"Initiates an OTA update by selecting one from an available collection"
6282+
createManualOtaOperationExistingBaseImage(
6283+
input: CreateManualOtaOperationExistingBaseImageInput!
6284+
): CreateManualOtaOperationExistingBaseImageResult
62636285

62646286
"Creates a new device group."
62656287
createDeviceGroup(input: CreateDeviceGroupInput!): CreateDeviceGroupResult

0 commit comments

Comments
 (0)