1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
use holo_hash::*;
use holochain_types::prelude::*;
use holochain_zome_types::cell::CellId;
use kitsune_p2p::agent_store::AgentInfoSigned;

use crate::{FullStateDump, InstalledAppInfo};

/// Represents the available conductor functions to call over an Admin interface
/// and will result in a corresponding [`AdminResponse`] message being sent back over the
/// interface connection.
/// Enum variants follow a general convention of `verb_noun` as opposed to
/// the `noun_verb` of `AdminResponse`.
///
/// Expects a serialized object with any contents of the enum on a key `data`
/// and the enum variant on a key `type`, e.g.
/// `{ type: 'enable_app', data: { installed_app_id: 'test_app' } }`
///
/// [`AdminResponse`]: enum.AdminResponse.html
#[derive(Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
#[serde(rename_all = "snake_case", tag = "type", content = "data")]
pub enum AdminRequest {
    /// Set up and register one or more new Admin interfaces
    /// as specified by a list of configurations. See [`AdminInterfaceConfig`]
    /// for details on the configuration.
    ///
    /// Will be responded to with an [`AdminResponse::AdminInterfacesAdded`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminInterfaceConfig`]: ../config/struct.AdminInterfaceConfig.html
    /// [`AdminResponse::AdminInterfacesAdded`]: enum.AdminResponse.html#variant.AdminInterfacesAdded
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    AddAdminInterfaces(Vec<crate::config::AdminInterfaceConfig>),

    /// Register a DNA for later use in InstallApp
    /// Stores the given DNA into the holochain dnas database and returns the hash of the DNA
    /// Will be responded to with an [`AdminResponse::DnaRegistered`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`RegisterDnaPayload`]: ../../../holochain_types/app/struct.RegisterDnaPayload.html
    /// [`AdminResponse::DnaRegistered`]: enum.AdminResponse.html#variant.DnaRegistered
    RegisterDna(Box<RegisterDnaPayload>),

    /// "Clone" a DNA (in the biological sense), thus creating a new Cell.
    ///
    /// Using the provided, already-registered DNA, create a new DNA with a unique
    /// UID and the specified properties, create a new Cell from this cloned DNA,
    /// and add the Cell to the specified App.
    ///
    /// Will be responded to with an [`AdminResponse::DnaCloned`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`CreateCloneCellPayload`]: ../../../holochain_types/app/struct.CreateCloneCellPayload.html
    /// [`AdminResponse::DnaCloned`]: enum.AdminResponse.html#variant.DnaCloned
    CreateCloneCell(Box<CreateCloneCellPayload>),

    /// Install an app from a list of `Dna` paths.
    /// Triggers genesis to be run on all `Cell`s and to be stored.
    /// An `App` is intended for use by
    /// one and only one Agent and for that reason it takes an `AgentPubKey` and
    /// installs all the Dnas with that `AgentPubKey` forming new `Cell`s.
    /// See [`InstallAppPayload`] for full details on the configuration.
    ///
    /// Note that the new `App` will not be enabled automatically after installation
    /// and can be enabled by calling [`AdminRequest::EnableApp`].
    ///
    /// Will be responded to with an [`AdminResponse::AppInstalled`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`InstallAppPayload`]: ../../../holochain_types/app/struct.InstallAppPayload.html
    /// [`AdminRequest::EnableApp`]: enum.AdminRequest.html#variant.EnableApp
    /// [`AdminResponse::AppInstalled`]: enum.AdminResponse.html#variant.AppInstalled
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    InstallApp(Box<InstallAppPayload>),

    /// Install an app using an [`AppBundle`].
    ///
    /// Triggers genesis to be run on all `Cell`s and to be stored.
    /// An `App` is intended for use by
    /// one and only one Agent and for that reason it takes an `AgentPubKey` and
    /// installs all the Dnas with that `AgentPubKey` forming new `Cell`s.
    /// See [`InstallAppBundlePayload`] for full details on the configuration.
    ///
    /// Note that the new `App` will not be enabled automatically after installation
    /// and can be enabled by calling [`AdminRequest::EnableApp`].
    ///
    /// Will be responded to with an [`AdminResponse::AppInstalled`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`InstallAppBundlePayload`]: ../../../holochain_types/app/struct.InstallAppBundlePayload.html
    /// [`AdminRequest::EnableApp`]: enum.AdminRequest.html#variant.EnableApp
    /// [`AdminResponse::AppInstalled`]: enum.AdminResponse.html#variant.AppInstalled
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    InstallAppBundle(Box<InstallAppBundlePayload>),

    /// Uninstalls the `App` specified by argument `installed_app_id` from the conductor,
    /// meaning that the app will be removed from the list of installed apps, and any Cells
    /// which were referenced only by this app will be disabled and removed, clearing up
    /// any persisted data.
    /// Cells which are still referenced by other installed apps will not be removed.
    ///
    /// Will be responded to with an [`AdminResponse::AppUninstalled`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::AppUninstalled`]: enum.AdminResponse.html#variant.AppUninstalled
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    UninstallApp {
        /// The InstalledAppId to uninstall
        installed_app_id: InstalledAppId,
    },

    /// List the hashes of all installed `Dna`s.
    /// Takes no arguments.
    ///
    /// Will be responded to with an [`AdminResponse::DnasListed`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::DnasListed`]: enum.AdminResponse.html#variant.DnasListed
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    ListDnas,

    /// Generate a new AgentPubKey.
    /// Takes no arguments.
    ///
    /// Will be responded to with an [`AdminResponse::AgentPubKeyGenerated`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::AgentPubKeyGenerated`]: enum.AdminResponse.html#variant.AgentPubKeyGenerated
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    GenerateAgentPubKey,

    /// List all the cell ids in the conductor.
    /// Takes no arguments.
    ///
    /// Will be responded to with an [`AdminResponse::CellIdsListed`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::CellIdsListed`]: enum.AdminResponse.html#variant.CellIdsListed
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    ListCellIds,

    /// List the ids of all the enabled Apps in the conductor.
    /// Takes no arguments.
    ///
    /// Will be responded to with an [`AdminResponse::ActiveAppsListed`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::ActiveAppsListed`]: enum.AdminResponse.html#variant.ActiveAppsListed
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    ListEnabledApps,

    /// DEPRECATED. Alias for ListEnabledApps.
    #[deprecated = "alias for ListEnabledApps"]
    ListActiveApps,

    /// List the ids of the Apps that are installed in the conductor, returning their information.
    /// If `status_filter` is `Some(_)`, it will return only the `Apps` with the specified status
    ///
    /// Will be responded to with an [`AdminResponse::AppsListed`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::AppsListed`]: enum.AdminResponse.html#variant.AppsListed
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    ListApps {
        status_filter: Option<AppStatusFilter>,
    },

    /// Changes the `App` specified by argument `installed_app_id` from a disabled state to an enabled state in the conductor,
    /// meaning that Zome calls can now be made and the `App` will be loaded on a reboot of the conductor.
    /// It is likely to want to call this after calling [`AdminRequest::InstallApp`], since a freshly
    /// installed `App` is not activated automatically.
    ///
    /// Will be responded to with an [`AdminResponse::AppEnabled`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminRequest::InstallApp`]: enum.AdminRequest.html#variant.InstallApp
    /// [`AdminResponse::AppEnabled`]: enum.AdminResponse.html#variant.AppEnabled
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    EnableApp {
        /// The InstalledAppId to enable
        installed_app_id: InstalledAppId,
    },

    /// DEPRECATED. Alias for EnableApp.
    #[deprecated = "alias for EnableApp"]
    ActivateApp {
        /// The InstalledAppId to enable
        installed_app_id: InstalledAppId,
    },

    /// Changes the `App` specified by argument `installed_app_id` from an enabled state to a disabled state in the conductor,
    /// meaning that Zome calls can no longer be made, and the `App` will not be loaded on a
    /// reboot of the conductor.
    ///
    /// Will be responded to with an [`AdminResponse::AppDisabled`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::AppDisabled`]: enum.AdminResponse.html#variant.AppDisabled
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    DisableApp {
        /// The InstalledAppId to disable
        installed_app_id: InstalledAppId,
    },

    /// DEPRECATED. Alias for DisableApp.
    #[deprecated = "alias for DisableApp"]
    DeactivateApp {
        /// The InstalledAppId to disable
        installed_app_id: InstalledAppId,
    },

    StartApp {
        /// The InstalledAppId to (re)start
        installed_app_id: InstalledAppId,
    },

    /// Open up a new websocket interface at the networking port
    /// (optionally) specified by argument `port` (or using any free port if argument `port` is `None`)
    /// over which you can then use the [`AppRequest`] API.
    /// Any active `App` will be callable via this interface.
    /// The successful [`AdminResponse::AppInterfaceAttached`] message will contain
    /// the port chosen by the conductor if `None` was passed.
    ///
    /// Will be responded to with an [`AdminResponse::AppInterfaceAttached`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::AppInterfaceAttached`]: enum.AdminResponse.html#variant.AppInterfaceAttached
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    AttachAppInterface {
        /// Optional port, use None to let the
        /// OS choose a free port
        port: Option<u16>,
    },

    /// List all the app interfaces currently attached with [`AttachAppInterface`].
    ListAppInterfaces,

    /// Dump the state of the `Cell` specified by argument `cell_id`,
    /// including its chain, as a string containing JSON.
    ///
    /// Will be responded to with an [`AdminResponse::StateDumped`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    /// [`AdminResponse::StateDumped`]: enum.AdminResponse.html#variant.StateDumped
    DumpState {
        /// The `CellId` for which to dump state
        cell_id: Box<CellId>,
    },

    /// Dump the full state of the `Cell` specified by argument `cell_id`,
    /// including its chain and DHT shard, as a string containing JSON.
    ///
    /// Warning: this API call is subject to change, and will not be available to hApps.
    /// This is meant to be used by introspection tooling.
    ///
    /// Note that the response to this call can be very big, as it's requesting for
    /// the full database of the Cell.
    ///
    /// Also note that while DHT Ops about private entries will be returned (like `StoreElement`),
    /// the entry in itself will be missing, as it's not actually stored publicly in the DHT shard.
    ///
    /// Will be responded to with an [`AdminResponse::FullStateDumped`]
    /// or an [`AdminResponse::Error`]
    ///
    /// [`AdminResponse::Error`]: enum.AppResponse.html#variant.Error
    /// [`AdminResponse::FullStateDumped`]: enum.AdminResponse.html#variant.FullStateDumped
    DumpFullState {
        /// The `CellId` for which to dump state
        cell_id: Box<CellId>,
        /// The last seen DhtOp RowId, returned in [`FullIntegrationDump`]
        /// Only DhtOps with RowId greater than the cursor will be returned
        dht_ops_cursor: Option<u64>,
    },

    /// Add a list [AgentInfoSigned] to this conductor's peer store.
    /// This is another way of finding peers on a dht.
    ///
    /// This can be useful for testing.
    ///
    /// It is also helpful if you know other
    /// agents on the network and they can send you
    /// their agent info.
    AddAgentInfo {
        /// Vec of signed agent info to add to peer store
        agent_infos: Vec<AgentInfoSigned>,
    },

    /// Request the [AgentInfoSigned] stored in this conductor's
    /// peer store.
    ///
    /// You can:
    /// - Get all agent info by leaving cell id to None.
    /// - Get a specific agent info by setting the cell id.
    ///
    /// This is how you can send your agent info to another agent.
    /// It is also useful for testing across networks.
    RequestAgentInfo {
        /// Optionally choose a specific agent info
        cell_id: Option<CellId>,
    },
}

/// Represents the possible responses to an [`AdminRequest`]
/// and follows a general convention of `noun_verb` as opposed to
/// the `verb_noun` of `AdminRequest`.
///
/// Will serialize as an object with any contents of the enum on a key `data`
/// and the enum variant on a key `type`, e.g.
/// `{ type: 'app_interface_attached', data: { port: 4000 } }`
///
/// [`AdminRequest`]: enum.AdminRequest.html
#[derive(Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
#[cfg_attr(test, derive(Clone))]
#[serde(rename_all = "snake_case", tag = "type", content = "data")]
pub enum AdminResponse {
    /// Can occur in response to any [`AdminRequest`].
    ///
    /// There has been an error during the handling of the request.
    /// See [`ExternalApiWireError`] for variants.
    ///
    /// [`AdminRequest`]: enum.AdminRequest.html
    /// [`ExternalApiWireError`]: error/enum.ExternalApiWireError.html
    Error(ExternalApiWireError),

    /// The successful response to an [`AdminRequest::RegisterDna`]
    ///
    /// [`AdminRequest::RegisterDna`]: enum.AdminRequest.html#variant.RegisterDna
    DnaRegistered(DnaHash),

    /// The successful response to an [`AdminRequest::InstallApp`].
    ///
    /// The resulting [`InstalledAppInfo`] contains the App id,
    /// the [`AppRoleId`]s and, most usefully, the new [`CellId`]s
    /// of the newly installed `Dna`s. See the [`InstalledAppInfo`] docs for details.
    ///
    /// [`AdminRequest::InstallApp`]: enum.AdminRequest.html#variant.InstallApp
    /// [`InstalledAppInfo`]: ../../../holochain_types/app/struct.InstalledAppInfo.html
    /// [`AppRoleId`]: ../../../holochain_types/app/type.AppRoleId.html
    /// [`CellId`]: ../../../holochain_types/cell/struct.CellId.html
    AppInstalled(InstalledAppInfo),

    /// The successful response to an [`AdminRequest::InstallAppBundle`].
    ///
    /// The resulting [`InstalledAppInfo`] contains the App id,
    /// the [`AppRoleId`]s and, most usefully, the new [`CellId`]s
    /// of the newly installed `Dna`s. See the [`InstalledAppInfo`] docs for details.
    ///
    /// [`AdminRequest::InstallApp`]: enum.AdminRequest.html#variant.InstallApp
    /// [`InstalledAppInfo`]: ../../../holochain_types/app/struct.InstalledAppInfo.html
    /// [`AppRoleId`]: ../../../holochain_types/app/type.AppRoleId.html
    /// [`CellId`]: ../../../holochain_types/cell/struct.CellId.html
    AppBundleInstalled(InstalledAppInfo),

    /// The succesful response to an [`AdminRequest::UninstallApp`].
    ///
    /// It means the `App` was uninstalled successfully.
    ///
    /// [`AdminRequest::UninstallApp`]: enum.AdminRequest.html#variant.UninstallApp
    AppUninstalled,

    /// The successful response to an [`AdminRequest::CreateCloneCell`].
    ///
    /// The response contains the [`CellId`] of the newly created clone.
    ///
    /// [`AdminRequest::CreateCloneCell`]: enum.AdminRequest.html#variant.CreateCloneCell
    /// [`CellId`]: ../../../holochain_types/cell/struct.CellId.html
    CloneCellCreated(CellId),

    /// The succesful response to an [`AdminRequest::AddAdminInterfaces`].
    ///
    /// It means the `AdminInterface`s have successfully been added
    ///
    /// [`AdminRequest::AddAdminInterfaces`]: enum.AdminRequest.html#variant.AddAdminInterfaces
    AdminInterfacesAdded,

    /// The succesful response to an [`AdminRequest::GenerateAgentPubKey`].
    ///
    /// Contains a new `AgentPubKey` generated by the Keystore
    ///
    /// [`AdminRequest::GenerateAgentPubKey`]: enum.AdminRequest.html#variant.GenerateAgentPubKey
    AgentPubKeyGenerated(AgentPubKey),

    /// The successful response to an [`AdminRequest::ListDnas`].
    ///
    /// Contains a list of the hashes of all installed `Dna`s
    ///
    /// [`AdminRequest::ListDnas`]: enum.AdminRequest.html#variant.ListDnas
    DnasListed(Vec<DnaHash>),

    /// The succesful response to an [`AdminRequest::ListCellIds`].
    ///
    /// Contains a list of all the `Cell` ids in the conductor
    ///
    /// [`AdminRequest::ListCellIds`]: enum.AdminRequest.html#variant.ListCellIds
    CellIdsListed(Vec<CellId>),

    /// The succesful response to an [`AdminRequest::ListEnabledApps`].
    ///
    /// Contains a list of all the active `App` ids in the conductor
    ///
    /// [`AdminRequest::ListEnabledApps`]: enum.AdminRequest.html#variant.ListEnabledApps
    EnabledAppsListed(Vec<InstalledAppId>),

    #[deprecated = "alias for EnabledAppsListed"]
    ActiveAppsListed(Vec<InstalledAppId>),

    /// The succesful response to an [`AdminRequest::ListApps`].
    ///
    /// Contains a list of the `InstalledAppInfo` of the installed `Apps` in the conductor
    ///
    /// [`AdminRequest::ListApps`]: enum.AdminRequest.html#variant.ListApps
    AppsListed(Vec<InstalledAppInfo>),

    /// The succesful response to an [`AdminRequest::AttachAppInterface`].
    ///
    /// `AppInterfaceApi` successfully attached.
    /// Contains the port number that was selected (if not specified) by Holochain
    /// for running this App interface
    ///
    /// [`AdminRequest::AttachAppInterface`]: enum.AdminRequest.html#variant.AttachAppInterface
    AppInterfaceAttached {
        /// Networking port of the new `AppInterfaceApi`
        port: u16,
    },

    /// The list of attached app interfaces.
    AppInterfacesListed(Vec<u16>),

    /// The succesful response to an [`AdminRequest::EnableApp`].
    ///
    /// It means the `App` was enabled successfully. If it was possible to
    /// put the app in a Running state, it will be Running, otherwise it will
    /// be Paused.
    ///
    /// [`AdminRequest::EnableApp`]: enum.AdminRequest.html#variant.EnableApp
    AppEnabled {
        app: InstalledAppInfo,
        errors: Vec<(CellId, String)>,
    },

    #[deprecated = "alias for AppEnabled"]
    AppActivated {
        app: InstalledAppInfo,
        errors: Vec<(CellId, String)>,
    },

    /// The succesful response to an [`AdminRequest::DisableApp`].
    ///
    /// It means the `App` was disabled successfully.
    ///
    /// [`AdminRequest::DisableApp`]: enum.AdminRequest.html#variant.DisableApp
    AppDisabled,

    /// The succesful response to an [`AdminRequest::StartApp`].
    ///
    /// The boolean determines whether or not the was actually started.
    /// If false, it was because the app was in a disabled state, or the app
    /// failed to start.
    /// TODO: add reason why app couldn't start
    ///
    /// [`AdminRequest::StartApp`]: enum.AdminRequest.html#variant.StartApp
    AppStarted(bool),

    #[deprecated = "alias for AppDisabled"]
    AppDeactivated,

    /// The succesful response to an [`AdminRequest::DumpState`].
    ///
    /// The result contains a string of serialized JSON data which can be deserialized to access the
    /// full state dump, and inspect the source chain.
    ///
    /// [`AdminRequest::DumpState`]: enum.AdminRequest.html#variant.DumpState
    StateDumped(String),

    /// The succesful response to an [`AdminRequest::DumpFullState`].
    ///
    /// The result contains a string of serialized JSON data which can be deserialized to access the
    /// full state dump, and inspect the source chain.
    ///
    /// Note that this result can be very big, as it's requesting for the full database of the Cell.
    ///
    /// [`AdminRequest::DumpFullState`]: enum.AdminRequest.html#variant.DumpFullState
    FullStateDumped(FullStateDump),

    /// The succesful response to an [`AdminRequest::AddAgentInfo`].
    ///
    /// This means the agent info was successfully added to the peer store.
    ///
    /// [`AdminRequest::AddAgentInfo`]: enum.AdminRequest.html#variant.AddAgentInfo
    AgentInfoAdded,

    /// The succesful response to an [`AdminRequest::RequestAgentInfo`].
    ///
    /// This is all the agent info that was found for the request.
    ///
    /// [`AdminRequest::RequestAgentInfo`]: enum.AdminRequest.html#variant.RequestAgentInfo
    AgentInfoRequested(Vec<AgentInfoSigned>),
}

/// Error type that goes over the websocket wire.
/// This intends to be application developer facing
/// so it should be readable and relevant
#[derive(Debug, serde::Serialize, serde::Deserialize, SerializedBytes, Clone)]
#[serde(rename_all = "snake_case", tag = "type", content = "data")]
pub enum ExternalApiWireError {
    // TODO: B-01506 Constrain these errors so they are relevant to
    // application developers and what they would need
    // to react to using code (i.e. not just print)
    /// Any internal error
    InternalError(String),
    /// The input to the api failed to Deseralize
    Deserialization(String),
    /// The dna path provided was invalid
    DnaReadError(String),
    /// There was an error in the ribosome
    RibosomeError(String),
    /// Error activating app
    ActivateApp(String),
    /// The zome call is unauthorized
    ZomeCallUnauthorized(String),
    /// A countersigning session has failed.
    CountersigningSessionError(String),
}

impl ExternalApiWireError {
    /// Convert the error from the display.
    pub fn internal<T: std::fmt::Display>(e: T) -> Self {
        // Display format is used because
        // this version intended for users.
        ExternalApiWireError::InternalError(e.to_string())
    }
}

#[derive(Debug, serde::Serialize, serde::Deserialize, SerializedBytes, Clone)]
/// Filter for `ListApps`.
pub enum AppStatusFilter {
    Enabled,
    Disabled,
    Running,
    Stopped,
    Paused,
}