azure_iot_operations_services/azure_device_registry/models/asset.rs
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 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//! Asset/Dataset models for Azure Device Registry operations.
use std::collections::HashMap;
use azure_iot_operations_mqtt::control_packet::QoS as MqttQoS;
use chrono::{DateTime, Utc};
use crate::azure_device_registry::adr_base_gen::adr_base_service::client as base_client_gen;
use crate::azure_device_registry::helper::{ConvertOptionMap, ConvertOptionVec};
use crate::azure_device_registry::{ConfigError, ConfigStatus};
// ~~~~~~~~~~~~~~~~~~~Asset DTDL Equivalent Structs~~~~~~~~~~~~~~
/// Represents an Asset in the Azure Device Registry service.
#[derive(Clone, Debug, PartialEq)]
pub struct Asset {
/// URIs or type definition IDs.
pub asset_type_refs: Vec<String>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// A set of key-value pairs that contain custom attributes set by the customer.
pub attributes: HashMap<String, String>, // if None on generated model, we can represent as empty hashmap
/// Array of data sets that are part of the asset. Each data set describes the data points that make up the set.
pub datasets: Vec<Dataset>, // if None on generated model, we can represent as empty vec
/// Stringified JSON that contains connector-specific default configuration for all datasets. Each dataset can have its own configuration that overrides the default settings here.
pub default_datasets_configuration: Option<String>,
/// Default destinations for a dataset.
pub default_datasets_destinations: Vec<DatasetDestination>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// Stringified JSON that contains connector-specific default configuration for all events. Each event can have its own configuration that overrides the default settings here.
pub default_events_configuration: Option<String>,
/// Default destinations for an event.
pub default_events_destinations: Vec<EventStreamDestination>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// Stringified JSON that contains connector-specific default configuration for all management groups. Each management group can have its own configuration that overrides the default settings here.
pub default_management_groups_configuration: Option<String>,
/// Stringified JSON that contains connector-specific default configuration for all streams. Each stream can have its own configuration that overrides the default settings here.
pub default_streams_configuration: Option<String>,
/// Default destinations for a stream.
pub default_streams_destinations: Vec<EventStreamDestination>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// Human-readable description of the asset.
pub description: Option<String>,
/// Reference to the device that provides data for this asset. Must provide device name & endpoint on the device to use.
pub device_ref: DeviceRef,
/// Reference to a list of discovered assets. Populated only if the asset has been created from discovery flow. Discovered asset names must be provided.
pub discovered_asset_refs: Vec<String>, // if None on generated model, we can represent as empty vec
/// Human-readable display name.
pub display_name: Option<String>,
/// Asset documentation reference.
pub documentation_uri: Option<String>,
/// Enabled/Disabled status of the asset.
pub enabled: Option<bool>, // TODO: just bool?
/// Array of events that are part of the asset. Each event can have per-event configuration.
pub events: Vec<Event>, // if None on generated model, we can represent as empty vec
/// Asset ID provided by the customer.
pub external_asset_id: Option<String>,
/// Revision number of the hardware.
pub hardware_revision: Option<String>,
/// A timestamp (in UTC) that is updated each time the resource is modified.
pub last_transition_time: Option<DateTime<Utc>>,
/// Array of management groups that are part of the asset.
pub management_groups: Vec<ManagementGroup>, // if None on generated model, we can represent as empty vec
/// Asset manufacturer.
pub manufacturer: Option<String>,
/// Asset manufacturer URI.
pub manufacturer_uri: Option<String>,
/// Asset model.
pub model: Option<String>,
/// Asset product code.
pub product_code: Option<String>,
/// Asset serial number.
pub serial_number: Option<String>,
/// Asset software revision number.
pub software_revision: Option<String>,
/// Array of streams that are part of the asset. Each stream can have per-stream configuration.
pub streams: Vec<Stream>, // if None on generated model, we can represent as empty vec
/// Globally unique, immutable, non-reusable id.
pub uuid: Option<String>,
/// An integer that is incremented each time the resource is modified in the cloud.
pub version: Option<u64>,
}
/// Represents a Discovered Asset in the Azure Device Registry service.
#[derive(Clone, Debug)]
pub struct DiscoveredAsset {
/// URIs or type definition IDs for the asset type.
pub asset_type_refs: Vec<String>, // if empty, we can represent as None on generated model.
/// A set of key-value pairs that contain custom attributes.
pub attributes: HashMap<String, String>, // if empty, we can represent as None on generated model.
/// Array of datasets that are part of the asset.
/// Each data set spec describes the data points that make up the set.
pub datasets: Vec<DiscoveredDataset>, // if empty, we can represent as None on generated model
/// Stringified JSON that contains connector-specific default configuration for all datasets.
/// Each dataset can have its own configuration that overrides the default settings here.
pub default_datasets_configuration: Option<String>,
/// Default destinations for a dataset.
pub default_datasets_destinations: Vec<DatasetDestination>, // if empty, we can represent as None on generated model.
/// Stringified JSON that contains connector-specific default configuration for all events.
/// Each event can have its own configuration that overrides the default settings here.
pub default_events_configuration: Option<String>,
/// Default destinations for an event.
pub default_events_destinations: Vec<EventStreamDestination>, // if empty, we can represent as None on generated model.
/// Stringified JSON that contains connector-specific default configuration for all management groups.
/// Each management group can have its own configuration that overrides the default settings here.
pub default_management_groups_configuration: Option<String>,
/// Stringified JSON that contains connector-specific default configuration for all streams.
/// Each stream can have its own configuration that overrides the default settings here.
pub default_streams_configuration: Option<String>,
/// Default destinations for a stream.
pub default_streams_destinations: Vec<EventStreamDestination>, // if empty, we can represent as None on generated model.
/// Reference to the device that provides data for this asset.
/// Must provide device name & endpoint on the device to use.
pub device_ref: DeviceRef,
/// Asset documentation reference.
pub documentation_uri: Option<String>,
/// Array of events that are part of the asset. Each event can have per-event configuration.
pub events: Vec<DiscoveredEvent>, // if empty, we can represent as None on generated model.
/// Asset hardware revision number.
pub hardware_revision: Option<String>,
/// Array of management groups that are part of the asset.
/// Each management group can have a per-group configuration.
pub management_groups: Vec<DiscoveredManagementGroup>, // if empty, we can represent as None on generated model.
/// The name of the manufacturer.
pub manufacturer: Option<String>,
/// Asset manufacturer URI.
pub manufacturer_uri: Option<String>,
/// The model of the asset.
pub model: Option<String>,
/// The product code of the asset.
pub product_code: Option<String>,
/// The revision number of the software.
pub serial_number: Option<String>,
/// Asset software revision number.
pub software_revision: Option<String>,
/// Array of streams that are part of the asset. Each stream can have per-stream configuration.
pub streams: Vec<DiscoveredStream>, // if empty, we can represent as None on generated model.
}
/// Represents a dataset.
#[derive(Clone, Debug, PartialEq)]
pub struct Dataset {
/// Stringified JSON that contains connector-specific JSON string that describes configuration for the specific dataset.
pub dataset_configuration: Option<String>,
/// Array of data points that are part of the dataset.
pub data_points: Vec<DatasetDataPoint>, // if None on generated model, we can represent as empty vec
/// Name of the data source within a dataset.
pub data_source: Option<String>,
/// Destinations for a dataset.
pub destinations: Vec<DatasetDestination>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// Name of the dataset.
pub name: String,
/// URI or type definition ID.
pub type_ref: Option<String>,
}
/// Represents a discovered dataset.
#[derive(Clone, Debug)]
pub struct DiscoveredDataset {
/// Stringified JSON that contains connector-specific properties that describes configuration for the specific dataset.
pub dataset_configuration: Option<String>,
/// Array of data points that are part of the dataset. Each data point can have per-data-point configuration.
pub data_points: Vec<DiscoveredDatasetDataPoint>, // if empty, we can represent as None on generated model
/// Name of the data source within a dataset.
pub data_source: Option<String>,
/// Destinations for a dataset.
pub destinations: Vec<DatasetDestination>, // if empty, we can represent as None on generated model.
/// Timestamp (in UTC) indicating when the dataset was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// The name of the dataset.
pub name: String,
/// Type definition id or URI of the dataset
pub type_ref: Option<String>,
}
/// Represents a data point in a dataset.
#[derive(Clone, Debug, PartialEq)]
pub struct DatasetDataPoint {
/// Stringified JSON that contains connector-specific configuration for the data point.
pub data_point_configuration: Option<String>,
/// The address of the source of the data in the asset (e.g. URL) so that a client can access the data source on the asset.
pub data_source: String,
/// The name of the data point.
pub name: String,
/// URI or type definition ID.
pub type_ref: Option<String>,
}
/// Represents a data point in a discovered dataset.
#[derive(Clone, Debug)]
pub struct DiscoveredDatasetDataPoint {
/// Stringified JSON that contains connector-specific configuration for the data point.
pub data_point_configuration: Option<String>,
/// The address of the source of the data in the discovered asset (e.g. URL) so that a client can access the data source on the asset.
pub data_source: String,
/// UTC timestamp indicating when the data point was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// The name of the data point
pub name: Option<String>,
/// URI or type definition id
pub type_ref: Option<String>,
}
/// Represents the destination for a dataset.
#[derive(Clone, Debug, PartialEq)]
pub struct DatasetDestination {
/// The destination configuration.
pub configuration: DestinationConfiguration,
/// The target destination.
pub target: DatasetTarget,
}
// TODO: switch to this rust enum
// pub enum AssetDatasetsDestination {
// BrokerStateStore{key: String},
// Mqtt{ topic: String,
// qos: Option<Qos>,
// retain: Option<Retain>,
// ttl: Option<u64>},
// Storage {path: String},
// }
/// Represents the destination for an event or stream.
#[derive(Clone, Debug, PartialEq)]
pub struct EventStreamDestination {
/// The destination configuration.
pub configuration: DestinationConfiguration,
/// The target destination.
pub target: EventStreamTarget,
}
// TODO: switch to this rust enum
// pub enum EventStreamDestination {
// Mqtt{ topic: String,
// qos: Option<Qos>,
// retain: Option<Retain>,
// ttl: Option<u64>},
// Storage {path: String},
// }
/// A reference to the Device and Endpoint within the device (connection information) used by brokers to connect that provides data points for this asset.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DeviceRef {
/// Name of the device resource.
pub device_name: String,
/// The name of endpoint to use.
pub endpoint_name: String,
}
/// Represents an event in an asset.
#[derive(Clone, Debug, PartialEq)]
pub struct Event {
/// Array of data points that are part of the event. Each data point can have per-data-point configuration.
pub data_points: Vec<EventDataPoint>, // if None on generated model, we can represent as empty vec
/// Destinations for an event.
pub destinations: Vec<EventStreamDestination>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// Stringified JSON that contains connector-specific configuration for the specific event.
pub event_configuration: Option<String>,
/// The address of the notifier of the event in the asset (e.g. URL) so that a client can access the notifier on the asset.
pub event_notifier: String,
/// The name of the event.
pub name: String,
/// URI or type definition ID.
pub type_ref: Option<String>,
}
/// Represents an event in a discovered asset.
#[derive(Clone, Debug)]
pub struct DiscoveredEvent {
/// Array of data points that are part of the event. Each data point can have per-data-point configuration.
pub data_points: Vec<DiscoveredEventDataPoint>, // if empty, we can represent as None on generated model
/// The destination for the event.
pub destinations: Vec<EventStreamDestination>, // if empty, we can represent as None on generated model.
/// Stringified JSON that contains connector-specific configuration for the specific event.
pub event_configuration: Option<String>,
/// The address of the notifier of the event in the discovered asset (e.g. URL) so that a client can access the notifier on the asset.
pub event_notifier: String,
/// UTC timestamp indicating when the event was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// The name of the event.
pub name: String,
/// URI or type definition id of the event
pub type_ref: Option<String>,
}
/// Represents a management group
#[derive(Clone, Debug, PartialEq)]
pub struct ManagementGroup {
/// Array of actions that are part of the management group. Each action can have an individual configuration.
pub actions: Vec<ManagementGroupAction>, // if None on generated model, we can represent as empty vec
/// Default response timeout for all actions that are part of the management group.
pub default_time_out_in_seconds: Option<u32>,
/// Default MQTT topic path on which a client will receive the request for all actions that are part of the management group.
pub default_topic: Option<String>,
/// Stringified JSON that contains connector-specific configuration for the management group.
pub management_group_configuration: Option<String>,
/// Name of the management group.
pub name: String,
/// URI or type definition ID.
pub type_ref: Option<String>,
}
/// Represents a discovered management group
#[derive(Clone, Debug)]
pub struct DiscoveredManagementGroup {
/// Array of actions that are part of the management group. Each action can have an individual configuration.
pub actions: Vec<DiscoveredManagementGroupAction>, // if None on generated model, we can represent as empty vec
/// Default response timeout for all actions that are part of the management group.
pub default_time_out_in_seconds: Option<u32>,
/// Default MQTT topic path on which a client will receive the request for all actions that are part of the management group.
pub default_topic: Option<String>,
/// Timestamp (in UTC) indicating when the management group was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// Stringified JSON that contains connector-specific configuration for the management group.
pub management_group_configuration: Option<String>,
/// The name of the management group.
pub name: String,
/// URI or type definition id of the management group
pub type_ref: Option<String>,
}
/// Represents a management group action
#[derive(Clone, Debug, PartialEq)]
pub struct ManagementGroupAction {
/// Configuration for the action.
pub action_configuration: Option<String>,
/// Type of the action.
pub action_type: ActionType,
/// Name of the action.
pub name: String,
/// The target URI on which a client can invoke the specific action.
pub target_uri: String,
/// Response timeout for the action.
pub time_out_in_seconds: Option<u32>,
/// The MQTT topic path on which a client will receive the request for the action.
pub topic: Option<String>,
/// URI or type definition ID.
pub type_ref: Option<String>,
}
/// Represents a discovered management group action
#[derive(Clone, Debug)]
pub struct DiscoveredManagementGroupAction {
/// Configuration for the action.
pub action_configuration: Option<String>,
/// Type of the action.
pub action_type: ActionType,
/// Timestamp (in UTC) indicating when the management action was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// The name of the action.
pub name: String,
/// The target URI on which a client can invoke the specific action.
pub target_uri: String,
/// Response timeout for the action.
pub time_out_in_seconds: Option<u32>,
/// The MQTT topic path on which a client will receive the request for the action.
pub topic: Option<String>,
/// URI or type definition id of the management group action
pub type_ref: Option<String>,
}
/// Represents a stream for an asset.
#[derive(Clone, Debug, PartialEq)]
pub struct Stream {
/// Destinations for a Stream.
pub destinations: Vec<EventStreamDestination>, // if None on generated model, we can represent as empty vec. Can currently only be length of 1
/// Name of the stream definition.
pub name: String,
/// Stringified JSON that contains connector-specific JSON string that describes configuration for the specific stream.
pub stream_configuration: Option<String>,
/// URI or type definition ID.
pub type_ref: Option<String>,
}
/// Represents a stream for a discovered asset.
#[derive(Clone, Debug)]
pub struct DiscoveredStream {
/// Destinations for a stream.
pub destinations: Vec<EventStreamDestination>, // if empty we can represent as None on generated model.
/// Timestamp (in UTC) indicating when the stream was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// The name of the stream.
pub name: String,
/// Stringified JSON that contains connector-specific configuration that describes configuration for the specific stream.
pub stream_configuration: Option<String>,
/// URI or type definition id of the stream
pub type_ref: Option<String>,
}
/// A data point in an event.
#[derive(Clone, Debug, PartialEq)]
pub struct EventDataPoint {
/// Stringified JSON that contains connector-specific configuration for the data point.
pub data_point_configuration: Option<String>,
/// The address of the source of the data in the event (e.g. URL) so that a client can access the data source on the asset.
pub data_source: String,
/// The name of the data point.
pub name: String,
}
/// A data point in a discovered event.
#[derive(Clone, Debug)]
pub struct DiscoveredEventDataPoint {
/// Stringified JSON that contains connector-specific configuration for the data point.
pub data_point_configuration: Option<String>,
/// The address of the source of the data in the discovered asset (e.g. URL) so that a client can access the data source on the asset.
pub data_source: String,
/// UTC timestamp indicating when the data point was added or modified.
pub last_updated_on: Option<DateTime<Utc>>,
/// The name of the data point.
pub name: Option<String>,
}
// TODO: turn into rust enums for which of these options can correlate to which destination enums
/// The configuration for the destination
#[derive(Clone, Debug, PartialEq)]
pub struct DestinationConfiguration {
/// The Broker State Store destination configuration key.
pub key: Option<String>,
/// The Storage destination configuration path.
pub path: Option<String>,
/// The MQTT `QoS` setting.
pub qos: Option<QoS>,
/// When set to 'Keep', messages published to an MQTT broker will have the retain flag set.
pub retain: Option<Retain>,
/// The MQTT topic.
pub topic: Option<String>,
/// The MQTT TTL setting.
pub ttl: Option<u64>,
}
// ~~~~~~~~~~~~~~~~~~~Asset Status DTDL Equivalent Structs~~~~~~~
#[derive(Clone, Debug, Default, PartialEq)]
/// Represents the observed status of an asset.
pub struct AssetStatus {
/// The configuration status of the asset.
pub config: Option<ConfigStatus>,
/// Array of dataset statuses that describe the status of each dataset.
pub datasets: Option<Vec<DatasetEventStreamStatus>>,
/// Array of event statuses that describe the status of each event.
pub events: Option<Vec<DatasetEventStreamStatus>>,
/// Array of management group statuses that describe the status of each management group.
pub management_groups: Option<Vec<ManagementGroupStatus>>,
/// Array of stream statuses that describe the status of each stream.
pub streams: Option<Vec<DatasetEventStreamStatus>>,
}
#[derive(Clone, Debug, PartialEq)]
/// Represents the status for a dataset, event, or stream.
pub struct DatasetEventStreamStatus {
/// The name of the dataset/event/stream.
/// Must be unique within the status.datasets[i]/events[i]/streams[i] array.
/// This name is used to correlate between the spec and status dataset/event/stream information.
pub name: String,
/// The message schema reference.
pub message_schema_reference: Option<MessageSchemaReference>,
/// The last error that occurred while processing the dataset/event/stream.
pub error: Option<ConfigError>,
}
#[derive(Clone, Debug, PartialEq)]
/// Represents the status for a management group
pub struct ManagementGroupStatus {
/// Array of action statuses that describe the status of each action.
pub actions: Option<Vec<ActionStatus>>,
/// The name of the managementgroup. Must be unique within the status.managementGroup array. This name is used to correlate between the spec and status management group information.
pub name: String,
}
#[derive(Clone, Debug, PartialEq)]
/// Represents the status for an action associated with a management group.
pub struct ActionStatus {
/// The last error that occurred while processing the action.
pub error: Option<ConfigError>,
/// The name of the action. Must be unique within the status.managementGroup[i].actions array. This name is used to correlate between the spec and status management group action information.
pub name: String,
/// The request message schema reference.
pub request_message_schema_reference: Option<MessageSchemaReference>,
/// The response message schema reference.
pub response_message_schema_reference: Option<MessageSchemaReference>,
}
#[derive(Clone, Debug, PartialEq)]
/// Represents a reference to a schema, including its name, version, and namespace.
pub struct MessageSchemaReference {
/// The message schema name.
pub name: String,
/// The message schema version.
pub version: String,
/// The message schema registry namespace.
pub registry_namespace: String,
}
impl From<AssetStatus> for base_client_gen::AssetStatus {
fn from(value: AssetStatus) -> Self {
base_client_gen::AssetStatus {
config: value.config.map(Into::into),
datasets: value.datasets.option_vec_into(),
events: value.events.option_vec_into(),
management_groups: value.management_groups.option_vec_into(),
streams: value.streams.option_vec_into(),
}
}
}
impl From<DatasetEventStreamStatus> for base_client_gen::AssetDatasetEventStreamStatus {
fn from(value: DatasetEventStreamStatus) -> Self {
base_client_gen::AssetDatasetEventStreamStatus {
name: value.name,
message_schema_reference: value.message_schema_reference.map(Into::into),
error: value.error.map(Into::into),
}
}
}
impl From<ManagementGroupStatus>
for base_client_gen::AssetManagementGroupStatusSchemaElementSchema
{
fn from(value: ManagementGroupStatus) -> Self {
base_client_gen::AssetManagementGroupStatusSchemaElementSchema {
actions: value.actions.option_vec_into(),
name: value.name,
}
}
}
impl From<ActionStatus> for base_client_gen::AssetManagementGroupActionStatusSchemaElementSchema {
fn from(value: ActionStatus) -> Self {
base_client_gen::AssetManagementGroupActionStatusSchemaElementSchema {
error: value.error.map(Into::into),
name: value.name,
request_message_schema_reference: value
.request_message_schema_reference
.map(Into::into),
response_message_schema_reference: value
.response_message_schema_reference
.map(Into::into),
}
}
}
impl From<MessageSchemaReference> for base_client_gen::MessageSchemaReference {
fn from(value: MessageSchemaReference) -> Self {
base_client_gen::MessageSchemaReference {
schema_name: value.name,
schema_version: value.version,
schema_registry_namespace: value.registry_namespace,
}
}
}
// ~~~~~~~~~~~~~~~~~~~DTDL Equivalent Enums~~~~~~~
// TODO: remove in favor of Rust enum
/// The target of the event or stream.
#[derive(Clone, Debug, PartialEq)]
pub enum EventStreamTarget {
/// MQTT
Mqtt,
/// Storage
Storage,
}
#[derive(Clone, Debug, PartialEq)]
/// Represents the retain policy.
pub enum Retain {
/// Should be retained.
Keep,
/// Should not be retained.
Never,
}
// TODO: remove in favor of Rust enum
#[derive(Clone, Debug, PartialEq)]
/// Represents the target type for a dataset.
pub enum DatasetTarget {
/// Represents a broker state store dataset target.
BrokerStateStore,
/// Represents a MQTT dataset target.
Mqtt,
/// Represents a storage dataset target.
Storage,
}
#[derive(Clone, Debug, PartialEq)]
/// Represents the type of action that can be performed in an asset management group.
pub enum ActionType {
/// Represents a call action type.
Call,
/// Represents a read action type.
Read,
/// Represents a write action type.
Write,
}
/// Represents the MQTT Quality of Service level.
/// Currently does not include Quality of Service 2.
#[derive(Clone, Debug, Copy, PartialEq)]
pub enum QoS {
/// Quality of Service level 0 (At most once)
AtMostOnce,
/// Quality of Service level 1 (At least once)
AtLeastOnce,
}
impl From<Retain> for base_client_gen::Retain {
fn from(value: Retain) -> Self {
match value {
Retain::Keep => Self::Keep,
Retain::Never => Self::Never,
}
}
}
impl From<base_client_gen::AssetStatus> for AssetStatus {
fn from(value: base_client_gen::AssetStatus) -> Self {
AssetStatus {
config: value.config.map(Into::into),
datasets: value.datasets.option_vec_into(),
events: value.events.option_vec_into(),
management_groups: value.management_groups.option_vec_into(),
streams: value.streams.option_vec_into(),
}
}
}
impl From<base_client_gen::AssetManagementGroupStatusSchemaElementSchema>
for ManagementGroupStatus
{
fn from(value: base_client_gen::AssetManagementGroupStatusSchemaElementSchema) -> Self {
ManagementGroupStatus {
actions: value.actions.option_vec_into(),
name: value.name,
}
}
}
impl From<base_client_gen::AssetManagementGroupActionStatusSchemaElementSchema> for ActionStatus {
fn from(value: base_client_gen::AssetManagementGroupActionStatusSchemaElementSchema) -> Self {
ActionStatus {
error: value.error.map(Into::into),
name: value.name,
request_message_schema_reference: value
.request_message_schema_reference
.map(Into::into),
response_message_schema_reference: value
.response_message_schema_reference
.map(Into::into),
}
}
}
impl From<base_client_gen::AssetDatasetEventStreamStatus> for DatasetEventStreamStatus {
fn from(value: base_client_gen::AssetDatasetEventStreamStatus) -> Self {
DatasetEventStreamStatus {
name: value.name,
message_schema_reference: value.message_schema_reference.map(Into::into),
error: value.error.map(Into::into),
}
}
}
impl From<base_client_gen::MessageSchemaReference> for MessageSchemaReference {
fn from(value: base_client_gen::MessageSchemaReference) -> Self {
MessageSchemaReference {
name: value.schema_name,
version: value.schema_version,
registry_namespace: value.schema_registry_namespace,
}
}
}
impl From<base_client_gen::Asset> for Asset {
fn from(value: base_client_gen::Asset) -> Self {
Asset {
asset_type_refs: value.asset_type_refs.unwrap_or_default(),
attributes: value.attributes.unwrap_or_default(),
datasets: value.datasets.option_vec_into().unwrap_or_default(),
default_datasets_configuration: value.default_datasets_configuration,
default_datasets_destinations: value
.default_datasets_destinations
.option_vec_into()
.unwrap_or_default(),
default_events_configuration: value.default_events_configuration,
default_events_destinations: value
.default_events_destinations
.option_vec_into()
.unwrap_or_default(),
default_management_groups_configuration: value.default_management_groups_configuration,
default_streams_configuration: value.default_streams_configuration,
default_streams_destinations: value
.default_streams_destinations
.option_vec_into()
.unwrap_or_default(),
description: value.description,
device_ref: value.device_ref.into(),
discovered_asset_refs: value.discovered_asset_refs.unwrap_or_default(),
display_name: value.display_name,
documentation_uri: value.documentation_uri,
enabled: value.enabled,
events: value.events.option_vec_into().unwrap_or_default(),
external_asset_id: value.external_asset_id,
hardware_revision: value.hardware_revision,
last_transition_time: value.last_transition_time,
management_groups: value
.management_groups
.option_vec_into()
.unwrap_or_default(),
manufacturer: value.manufacturer,
manufacturer_uri: value.manufacturer_uri,
model: value.model,
product_code: value.product_code,
serial_number: value.serial_number,
software_revision: value.software_revision,
streams: value.streams.option_vec_into().unwrap_or_default(),
uuid: value.uuid,
version: value.version,
}
}
}
impl From<DiscoveredAsset> for base_client_gen::DiscoveredAsset {
fn from(value: DiscoveredAsset) -> Self {
base_client_gen::DiscoveredAsset {
asset_type_refs: value.asset_type_refs.option_vec_into(),
attributes: value.attributes.option_map_into(),
datasets: value.datasets.option_vec_into(),
default_datasets_configuration: value.default_datasets_configuration,
default_datasets_destinations: value.default_datasets_destinations.option_vec_into(),
default_events_configuration: value.default_events_configuration,
default_events_destinations: value.default_events_destinations.option_vec_into(),
default_management_groups_configuration: value.default_management_groups_configuration,
default_streams_configuration: value.default_streams_configuration,
default_streams_destinations: value.default_streams_destinations.option_vec_into(),
device_ref: value.device_ref.into(),
documentation_uri: value.documentation_uri,
events: value.events.option_vec_into(),
hardware_revision: value.hardware_revision,
management_groups: value.management_groups.option_vec_into(),
manufacturer: value.manufacturer,
manufacturer_uri: value.manufacturer_uri,
model: value.model,
product_code: value.product_code,
serial_number: value.serial_number,
software_revision: value.software_revision,
streams: value.streams.option_vec_into(),
}
}
}
impl From<base_client_gen::AssetDatasetSchemaElementSchema> for Dataset {
fn from(value: base_client_gen::AssetDatasetSchemaElementSchema) -> Self {
Dataset {
dataset_configuration: value.dataset_configuration,
data_points: value.data_points.option_vec_into().unwrap_or_default(),
data_source: value.data_source,
destinations: value.destinations.option_vec_into().unwrap_or_default(),
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<DiscoveredDataset> for base_client_gen::DiscoveredAssetDataset {
fn from(value: DiscoveredDataset) -> Self {
base_client_gen::DiscoveredAssetDataset {
dataset_configuration: value.dataset_configuration,
data_points: value.data_points.option_vec_into(),
data_source: value.data_source,
destinations: value.destinations.option_vec_into(),
last_updated_on: value.last_updated_on,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<base_client_gen::AssetDatasetDataPointSchemaElementSchema> for DatasetDataPoint {
fn from(value: base_client_gen::AssetDatasetDataPointSchemaElementSchema) -> Self {
DatasetDataPoint {
data_point_configuration: value.data_point_configuration,
data_source: value.data_source,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<DiscoveredDatasetDataPoint> for base_client_gen::DiscoveredAssetDatasetDataPoint {
fn from(value: DiscoveredDatasetDataPoint) -> Self {
base_client_gen::DiscoveredAssetDatasetDataPoint {
data_point_configuration: value.data_point_configuration,
data_source: value.data_source,
last_updated_on: value.last_updated_on,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<base_client_gen::DatasetDestination> for DatasetDestination {
fn from(value: base_client_gen::DatasetDestination) -> Self {
DatasetDestination {
configuration: value.configuration.into(),
target: value.target.into(),
}
}
}
impl From<DatasetDestination> for base_client_gen::DatasetDestination {
fn from(value: DatasetDestination) -> Self {
base_client_gen::DatasetDestination {
configuration: value.configuration.into(),
target: value.target.into(),
}
}
}
impl From<base_client_gen::AssetDeviceRef> for DeviceRef {
fn from(value: base_client_gen::AssetDeviceRef) -> Self {
DeviceRef {
device_name: value.device_name,
endpoint_name: value.endpoint_name,
}
}
}
impl From<DeviceRef> for base_client_gen::AssetDeviceRef {
fn from(value: DeviceRef) -> Self {
base_client_gen::AssetDeviceRef {
device_name: value.device_name,
endpoint_name: value.endpoint_name,
}
}
}
impl From<base_client_gen::AssetEventSchemaElementSchema> for Event {
fn from(value: base_client_gen::AssetEventSchemaElementSchema) -> Self {
Event {
data_points: value.data_points.option_vec_into().unwrap_or_default(),
destinations: value.destinations.option_vec_into().unwrap_or_default(),
event_configuration: value.event_configuration,
event_notifier: value.event_notifier,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<DiscoveredEvent> for base_client_gen::DiscoveredAssetEvent {
fn from(value: DiscoveredEvent) -> Self {
base_client_gen::DiscoveredAssetEvent {
data_points: value.data_points.option_vec_into(),
destinations: value.destinations.option_vec_into(),
event_configuration: value.event_configuration,
event_notifier: value.event_notifier,
last_updated_on: value.last_updated_on,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<base_client_gen::EventStreamDestination> for EventStreamDestination {
fn from(value: base_client_gen::EventStreamDestination) -> Self {
EventStreamDestination {
configuration: value.configuration.into(),
target: value.target.into(),
}
}
}
impl From<EventStreamDestination> for base_client_gen::EventStreamDestination {
fn from(value: EventStreamDestination) -> Self {
base_client_gen::EventStreamDestination {
configuration: value.configuration.into(),
target: value.target.into(),
}
}
}
impl From<base_client_gen::AssetEventDataPointSchemaElementSchema> for EventDataPoint {
fn from(value: base_client_gen::AssetEventDataPointSchemaElementSchema) -> Self {
EventDataPoint {
data_point_configuration: value.data_point_configuration,
data_source: value.data_source,
name: value.name,
}
}
}
impl From<DiscoveredEventDataPoint> for base_client_gen::DiscoveredAssetEventDataPoint {
fn from(value: DiscoveredEventDataPoint) -> Self {
base_client_gen::DiscoveredAssetEventDataPoint {
data_point_configuration: value.data_point_configuration,
data_source: value.data_source,
last_updated_on: value.last_updated_on,
name: value.name,
}
}
}
impl From<base_client_gen::AssetManagementGroupSchemaElementSchema> for ManagementGroup {
fn from(value: base_client_gen::AssetManagementGroupSchemaElementSchema) -> Self {
ManagementGroup {
actions: value.actions.option_vec_into().unwrap_or_default(),
default_time_out_in_seconds: value.default_time_out_in_seconds,
default_topic: value.default_topic,
management_group_configuration: value.management_group_configuration,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<DiscoveredManagementGroup> for base_client_gen::DiscoveredAssetManagementGroup {
fn from(value: DiscoveredManagementGroup) -> Self {
base_client_gen::DiscoveredAssetManagementGroup {
actions: value.actions.option_vec_into(),
default_time_out_in_seconds: value.default_time_out_in_seconds,
default_topic: value.default_topic,
last_updated_on: value.last_updated_on,
management_group_configuration: value.management_group_configuration,
name: value.name,
type_ref: value.type_ref,
}
}
}
impl From<base_client_gen::AssetManagementGroupActionSchemaElementSchema>
for ManagementGroupAction
{
fn from(value: base_client_gen::AssetManagementGroupActionSchemaElementSchema) -> Self {
ManagementGroupAction {
action_configuration: value.action_configuration,
action_type: value.action_type.into(),
name: value.name,
target_uri: value.target_uri,
time_out_in_seconds: value.time_out_in_seconds,
topic: value.topic,
type_ref: value.type_ref,
}
}
}
impl From<DiscoveredManagementGroupAction>
for base_client_gen::DiscoveredAssetManagementGroupAction
{
fn from(value: DiscoveredManagementGroupAction) -> Self {
base_client_gen::DiscoveredAssetManagementGroupAction {
action_configuration: value.action_configuration,
action_type: value.action_type.into(),
last_updated_on: value.last_updated_on,
name: value.name,
target_uri: value.target_uri,
time_out_in_seconds: value.time_out_in_seconds,
topic: value.topic,
type_ref: value.type_ref,
}
}
}
impl From<base_client_gen::AssetManagementGroupActionType> for ActionType {
fn from(value: base_client_gen::AssetManagementGroupActionType) -> Self {
match value {
base_client_gen::AssetManagementGroupActionType::Call => ActionType::Call,
base_client_gen::AssetManagementGroupActionType::Read => ActionType::Read,
base_client_gen::AssetManagementGroupActionType::Write => ActionType::Write,
}
}
}
impl From<ActionType> for base_client_gen::AssetManagementGroupActionType {
fn from(value: ActionType) -> Self {
match value {
ActionType::Call => Self::Call,
ActionType::Read => Self::Read,
ActionType::Write => Self::Write,
}
}
}
impl From<base_client_gen::AssetStreamSchemaElementSchema> for Stream {
fn from(value: base_client_gen::AssetStreamSchemaElementSchema) -> Self {
Stream {
destinations: value.destinations.option_vec_into().unwrap_or_default(),
name: value.name,
stream_configuration: value.stream_configuration,
type_ref: value.type_ref,
}
}
}
impl From<DiscoveredStream> for base_client_gen::DiscoveredAssetStream {
fn from(value: DiscoveredStream) -> Self {
base_client_gen::DiscoveredAssetStream {
destinations: value.destinations.option_vec_into(),
last_updated_on: value.last_updated_on,
name: value.name,
stream_configuration: value.stream_configuration,
type_ref: value.type_ref,
}
}
}
impl From<base_client_gen::DestinationConfiguration> for DestinationConfiguration {
fn from(value: base_client_gen::DestinationConfiguration) -> Self {
DestinationConfiguration {
key: value.key,
path: value.path,
qos: value.qos.map(Into::into),
retain: value.retain.map(Into::into),
topic: value.topic,
ttl: value.ttl,
}
}
}
impl From<DestinationConfiguration> for base_client_gen::DestinationConfiguration {
fn from(value: DestinationConfiguration) -> Self {
base_client_gen::DestinationConfiguration {
key: value.key,
path: value.path,
qos: value.qos.map(Into::into),
retain: value.retain.map(Into::into),
topic: value.topic,
ttl: value.ttl,
}
}
}
impl From<base_client_gen::EventStreamTarget> for EventStreamTarget {
fn from(value: base_client_gen::EventStreamTarget) -> Self {
match value {
base_client_gen::EventStreamTarget::Mqtt => EventStreamTarget::Mqtt,
base_client_gen::EventStreamTarget::Storage => EventStreamTarget::Storage,
}
}
}
impl From<EventStreamTarget> for base_client_gen::EventStreamTarget {
fn from(value: EventStreamTarget) -> Self {
match value {
EventStreamTarget::Mqtt => base_client_gen::EventStreamTarget::Mqtt,
EventStreamTarget::Storage => base_client_gen::EventStreamTarget::Storage,
}
}
}
impl From<base_client_gen::DatasetTarget> for DatasetTarget {
fn from(value: base_client_gen::DatasetTarget) -> Self {
match value {
base_client_gen::DatasetTarget::BrokerStateStore => DatasetTarget::BrokerStateStore,
base_client_gen::DatasetTarget::Mqtt => DatasetTarget::Mqtt,
base_client_gen::DatasetTarget::Storage => DatasetTarget::Storage,
}
}
}
impl From<DatasetTarget> for base_client_gen::DatasetTarget {
fn from(value: DatasetTarget) -> Self {
match value {
DatasetTarget::BrokerStateStore => base_client_gen::DatasetTarget::BrokerStateStore,
DatasetTarget::Mqtt => base_client_gen::DatasetTarget::Mqtt,
DatasetTarget::Storage => base_client_gen::DatasetTarget::Storage,
}
}
}
impl From<base_client_gen::Qos> for QoS {
fn from(value: base_client_gen::Qos) -> Self {
match value {
base_client_gen::Qos::Qos0 => QoS::AtMostOnce,
base_client_gen::Qos::Qos1 => QoS::AtLeastOnce,
}
}
}
impl From<QoS> for base_client_gen::Qos {
fn from(value: QoS) -> Self {
match value {
QoS::AtMostOnce => base_client_gen::Qos::Qos0,
QoS::AtLeastOnce => base_client_gen::Qos::Qos1,
}
}
}
impl From<QoS> for MqttQoS {
fn from(value: QoS) -> Self {
match value {
QoS::AtMostOnce => MqttQoS::AtMostOnce,
QoS::AtLeastOnce => MqttQoS::AtLeastOnce,
}
}
}
impl From<base_client_gen::Retain> for Retain {
fn from(value: base_client_gen::Retain) -> Self {
match value {
base_client_gen::Retain::Keep => Retain::Keep,
base_client_gen::Retain::Never => Retain::Never,
}
}
}