MCPcopy Create free account
hub / github.com/PowerShell/DSC / adapt

Function adapt

tools/dsctest/src/adapter.rs:55–212  ·  view source on GitHub ↗
(resource_type: &str, input: &str, operation: &AdapterOperation, resource_path: &Option<String>)

Source from the content-addressed store, hash-verified

53}
54
55pub fn adapt(resource_type: &str, input: &str, operation: &AdapterOperation, resource_path: &Option<String>) -> Result<String, String> {
56 match operation {
57 AdapterOperation::List => {
58 let resource_one = DscResource {
59 type_name: "Adapted/One".to_string(),
60 kind: "resource".to_string(),
61 version: "1.0.0".to_string(),
62 capabilities: vec!["get".to_string(), "set".to_string(), "test".to_string(), "export".to_string()],
63 path: "path/to/adapted/one".to_string(),
64 directory: "path/to/adapted".to_string(),
65 implemented_as: "TestAdapted".to_string(),
66 properties: vec!["one".to_string()],
67 require_adapter: Some("Test/Adapter".to_string()),
68 };
69 let resource_two = DscResource {
70 type_name: "Adapted/Two".to_string(),
71 kind: "resource".to_string(),
72 version: "1.0.0".to_string(),
73 capabilities: vec!["get".to_string(), "set".to_string(), "test".to_string(), "export".to_string()],
74 path: "path/to/adapted/two".to_string(),
75 directory: "path/to/adapted".to_string(),
76 implemented_as: "TestAdapted".to_string(),
77 properties: vec!["two".to_string()],
78 require_adapter: Some("Test/Adapter".to_string()),
79 };
80 println!("{}", serde_json::to_string(&resource_one).unwrap());
81 println!("{}", serde_json::to_string(&resource_two).unwrap());
82 std::process::exit(0);
83 },
84 AdapterOperation::Get => {
85 match resource_type {
86 "Adapted/One" => {
87 let adapted_one = AdaptedOne {
88 one: "value1".to_string(),
89 name: None,
90 path: resource_path.clone(),
91 };
92 Ok(serde_json::to_string(&adapted_one).unwrap())
93 },
94 "Adapted/Two" => {
95 let adapted_two = AdaptedTwo {
96 two: "value2".to_string(),
97 name: None,
98 path: resource_path.clone(),
99 };
100 Ok(serde_json::to_string(&adapted_two).unwrap())
101 },
102 "Adapted/Three" => {
103 let adapted_three = AdaptedOne {
104 one: "value3".to_string(),
105 name: None,
106 path: resource_path.clone(),
107 };
108 Ok(serde_json::to_string(&adapted_three).unwrap())
109 },
110 "Adapted/Deprecated" => {
111 let adapted_deprecated = AdaptedOne {
112 one: "deprecated".to_string(),

Callers 1

mainFunction · 0.85

Calls 2

to_stringFunction · 0.50
from_strFunction · 0.50

Tested by

no test coverage detected