pub struct Protocol {
pub name: String,
pub options: Option<HashMap<String, Value>>,
pub webdav: Option<WebDavProperties>,
pub webapp: Option<WebAppProperties>,
pub datatx: Option<DataTxProperties>,
pub additional_protocols: HashMap<String, Value>,
}
Expand description
JSON object with specific options for each protocol.
The supported protocols are:
webdav
, to access the datawebapp
, to access remote web applicationsdatatx
, to transfer the data to the remote endpoint
Other custom protocols might be added in the future.
§Single Protocol Legacy
use ocm_types::share::Protocol;
use std::collections::HashMap;
use serde_json::Value;
use serde_json::json;
#[allow(deprecated)]
let single_protocol_legacy = Protocol{
name: "webdav".to_string(),
options: Some(HashMap::from_iter(vec![
("sharedSecret".to_string(), Value::String("hfiuhworzwnur98d3wjiwhr".to_string())),
("permissions".to_string(), Value::String("some permissions scheme".to_string())),
].into_iter())),
..Default::default()
};
let json: Value = serde_json::from_str(r#"{
"name": "webdav",
"options": {
"sharedSecret": "hfiuhworzwnur98d3wjiwhr",
"permissions": "some permissions scheme"
}
}"#).unwrap();
assert_eq!(json!(single_protocol_legacy), json);
§Single Protocol New
use ocm_types::share::Protocol;
use ocm_types::share::WebDavProperties;
use ocm_types::share::WebDavPermissions;
use std::collections::HashMap;
use serde_json::Value;
use serde_json::json;
let single_protocol_new = Protocol{
name: "multi".to_string(),
webdav: Some(WebDavProperties{
uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
shared_secret: Some("hfiuhworzwnur98d3wjiwhr".to_string()),
permissions: vec![
WebDavPermissions::Read,
WebDavPermissions::Write,
],
requirements: vec![]
}),
..Default::default()
};
let json: Value = serde_json::from_str(r#"{
"name": "multi",
"webdav": {
"uri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
"sharedSecret": "hfiuhworzwnur98d3wjiwhr",
"permissions": ["read", "write"]
}
}"#).unwrap();
assert_eq!(json!(single_protocol_new), json);
§Multi Protocol
use ocm_types::share::Protocol;
use ocm_types::share::WebDavProperties;
use ocm_types::share::WebDavPermissions;
use ocm_types::share::WebDavRequirements;
use ocm_types::share::WebAppProperties;
use ocm_types::share::WebAppViewMode;
use ocm_types::share::DataTxProperties;
use std::collections::HashMap;
use serde_json::Value;
use serde_json::json;
let single_protocol_new = Protocol{
name: "multi".to_string(),
webdav: Some(WebDavProperties{
uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
shared_secret: Some("hfiuhworzwnur98d3wjiwhr".to_string()),
permissions: vec![
WebDavPermissions::Read,
WebDavPermissions::Write
],
requirements: vec![
WebDavRequirements::MfaEnforced
]
}),
webapp: Some(WebAppProperties{
uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
shared_secret: Some("hfiuhworzwnur98d3wjiwhr".to_string()),
view_mode: WebAppViewMode::Read
}),
datatx: Some(DataTxProperties{
src_uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
shared_secret: "hfiuhworzwnur98d3wjiwhr".to_string(),
size: Some(100000)
}),
..Default::default()
};
let json: Value = serde_json::from_str(r#"{
"name": "multi",
"webdav": {
"uri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
"sharedSecret": "hfiuhworzwnur98d3wjiwhr",
"permissions": ["read", "write"],
"requirements": ["mfa-enforced"]
},
"webapp": {
"uri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
"sharedSecret": "hfiuhworzwnur98d3wjiwhr",
"viewMode": "read"
},
"datatx": {
"srcUri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
"sharedSecret": "hfiuhworzwnur98d3wjiwhr",
"size": 100000
}
}"#).unwrap();
assert_eq!(json!(single_protocol_new), json);
Fields§
§name: String
The name of the protocol. Default: multi
.
If multi
is given, one or more protocol endpoints are expected
to be defined according to the optional properties specified below.
Otherwise, at least webdav
is expected to be supported, and
its options MAY be given in the opaque options
payload for
compatibility with v1.0 implementations (see examples). Note
though that this format is deprecated.
Warning: client implementers should be aware that v1.1 servers
MAY support both webdav
and multi
, but v1.0 servers MAY
only support webdav
.
This field may be removed in a future major version of the spec.
options: Option<HashMap<String, Value>>
This property is now deprecated. Implementations are encouraged to transition to the new optional properties defined below, such that this field may be removed in a future major version of the spec.
webdav: Option<WebDavProperties>
§webapp: Option<WebAppProperties>
§datatx: Option<DataTxProperties>
§additional_protocols: HashMap<String, Value>
Any optional additional protocols supported for this resource MAY be provided here, along with their custom payload. Appropriate capabilities MUST be advertised in order for a sender to ensure the recipient can parse such customized payloads.