Skip to main content

nominal_api/conjure/endpoints/scout/
units_service.rs

1use conjure_http::endpoint;
2/// The Units Service serves as a comprehensive catalog of the units of measurement supported by scout. Units, by
3/// default, follow the UCUM convention for representation.
4#[conjure_http::conjure_endpoints(name = "UnitsService", use_legacy_error_serialization)]
5pub trait UnitsService {
6    /// Returns all known units, grouped by the physical property they measure.
7    #[endpoint(
8        method = GET,
9        path = "/units/v1/units",
10        name = "getAllUnits",
11        produces = conjure_http::server::StdResponseSerializer
12    )]
13    fn get_all_units(
14        &self,
15        #[auth]
16        auth_: conjure_object::BearerToken,
17    ) -> Result<
18        super::super::super::objects::scout::units::api::GetUnitsResponse,
19        conjure_http::private::Error,
20    >;
21    /// Returns information for a unit symbol if available. Returns as empty if the provided symbol cannot be parsed.
22    #[endpoint(
23        method = POST,
24        path = "/units/v1/units/get-unit",
25        name = "getUnit",
26        produces = conjure_http::server::conjure::CollectionResponseSerializer
27    )]
28    fn get_unit(
29        &self,
30        #[auth]
31        auth_: conjure_object::BearerToken,
32        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
33        unit: super::super::super::objects::scout::units::api::UnitSymbol,
34    ) -> Result<
35        Option<super::super::super::objects::scout::units::api::Unit>,
36        conjure_http::private::Error,
37    >;
38    /// Returns information for the unit symbols if available. If the provided symbol cannot be parsed, it will be
39    /// omitted from the map.
40    #[endpoint(
41        method = POST,
42        path = "/units/v1/units/get-batch-units",
43        name = "getBatchUnits",
44        produces = conjure_http::server::conjure::CollectionResponseSerializer
45    )]
46    fn get_batch_units(
47        &self,
48        #[auth]
49        auth_: conjure_object::BearerToken,
50        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
51        units: std::collections::BTreeSet<
52            super::super::super::objects::scout::units::api::UnitSymbol,
53        >,
54    ) -> Result<
55        std::collections::BTreeMap<
56            super::super::super::objects::scout::units::api::UnitSymbol,
57            super::super::super::objects::scout::units::api::Unit,
58        >,
59        conjure_http::private::Error,
60    >;
61    /// Returns the set of cataloged units that can be converted to and from the given unit.
62    /// No commensurable units does not imply the unit is invalid. Use /get-unit to check for validity.
63    #[endpoint(
64        method = POST,
65        path = "/units/v1/units/commensurable-units",
66        name = "getCommensurableUnits",
67        produces = conjure_http::server::conjure::CollectionResponseSerializer
68    )]
69    fn get_commensurable_units(
70        &self,
71        #[auth]
72        auth_: conjure_object::BearerToken,
73        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
74        unit: super::super::super::objects::scout::units::api::UnitSymbol,
75    ) -> Result<
76        std::collections::BTreeSet<
77            super::super::super::objects::scout::units::api::Unit,
78        >,
79        conjure_http::private::Error,
80    >;
81}
82/// The Units Service serves as a comprehensive catalog of the units of measurement supported by scout. Units, by
83/// default, follow the UCUM convention for representation.
84#[conjure_http::conjure_endpoints(name = "UnitsService", use_legacy_error_serialization)]
85pub trait AsyncUnitsService {
86    /// Returns all known units, grouped by the physical property they measure.
87    #[endpoint(
88        method = GET,
89        path = "/units/v1/units",
90        name = "getAllUnits",
91        produces = conjure_http::server::StdResponseSerializer
92    )]
93    async fn get_all_units(
94        &self,
95        #[auth]
96        auth_: conjure_object::BearerToken,
97    ) -> Result<
98        super::super::super::objects::scout::units::api::GetUnitsResponse,
99        conjure_http::private::Error,
100    >;
101    /// Returns information for a unit symbol if available. Returns as empty if the provided symbol cannot be parsed.
102    #[endpoint(
103        method = POST,
104        path = "/units/v1/units/get-unit",
105        name = "getUnit",
106        produces = conjure_http::server::conjure::CollectionResponseSerializer
107    )]
108    async fn get_unit(
109        &self,
110        #[auth]
111        auth_: conjure_object::BearerToken,
112        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
113        unit: super::super::super::objects::scout::units::api::UnitSymbol,
114    ) -> Result<
115        Option<super::super::super::objects::scout::units::api::Unit>,
116        conjure_http::private::Error,
117    >;
118    /// Returns information for the unit symbols if available. If the provided symbol cannot be parsed, it will be
119    /// omitted from the map.
120    #[endpoint(
121        method = POST,
122        path = "/units/v1/units/get-batch-units",
123        name = "getBatchUnits",
124        produces = conjure_http::server::conjure::CollectionResponseSerializer
125    )]
126    async fn get_batch_units(
127        &self,
128        #[auth]
129        auth_: conjure_object::BearerToken,
130        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
131        units: std::collections::BTreeSet<
132            super::super::super::objects::scout::units::api::UnitSymbol,
133        >,
134    ) -> Result<
135        std::collections::BTreeMap<
136            super::super::super::objects::scout::units::api::UnitSymbol,
137            super::super::super::objects::scout::units::api::Unit,
138        >,
139        conjure_http::private::Error,
140    >;
141    /// Returns the set of cataloged units that can be converted to and from the given unit.
142    /// No commensurable units does not imply the unit is invalid. Use /get-unit to check for validity.
143    #[endpoint(
144        method = POST,
145        path = "/units/v1/units/commensurable-units",
146        name = "getCommensurableUnits",
147        produces = conjure_http::server::conjure::CollectionResponseSerializer
148    )]
149    async fn get_commensurable_units(
150        &self,
151        #[auth]
152        auth_: conjure_object::BearerToken,
153        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
154        unit: super::super::super::objects::scout::units::api::UnitSymbol,
155    ) -> Result<
156        std::collections::BTreeSet<
157            super::super::super::objects::scout::units::api::Unit,
158        >,
159        conjure_http::private::Error,
160    >;
161}
162/// The Units Service serves as a comprehensive catalog of the units of measurement supported by scout. Units, by
163/// default, follow the UCUM convention for representation.
164#[conjure_http::conjure_endpoints(
165    name = "UnitsService",
166    use_legacy_error_serialization,
167    local
168)]
169pub trait LocalAsyncUnitsService {
170    /// Returns all known units, grouped by the physical property they measure.
171    #[endpoint(
172        method = GET,
173        path = "/units/v1/units",
174        name = "getAllUnits",
175        produces = conjure_http::server::StdResponseSerializer
176    )]
177    async fn get_all_units(
178        &self,
179        #[auth]
180        auth_: conjure_object::BearerToken,
181    ) -> Result<
182        super::super::super::objects::scout::units::api::GetUnitsResponse,
183        conjure_http::private::Error,
184    >;
185    /// Returns information for a unit symbol if available. Returns as empty if the provided symbol cannot be parsed.
186    #[endpoint(
187        method = POST,
188        path = "/units/v1/units/get-unit",
189        name = "getUnit",
190        produces = conjure_http::server::conjure::CollectionResponseSerializer
191    )]
192    async fn get_unit(
193        &self,
194        #[auth]
195        auth_: conjure_object::BearerToken,
196        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
197        unit: super::super::super::objects::scout::units::api::UnitSymbol,
198    ) -> Result<
199        Option<super::super::super::objects::scout::units::api::Unit>,
200        conjure_http::private::Error,
201    >;
202    /// Returns information for the unit symbols if available. If the provided symbol cannot be parsed, it will be
203    /// omitted from the map.
204    #[endpoint(
205        method = POST,
206        path = "/units/v1/units/get-batch-units",
207        name = "getBatchUnits",
208        produces = conjure_http::server::conjure::CollectionResponseSerializer
209    )]
210    async fn get_batch_units(
211        &self,
212        #[auth]
213        auth_: conjure_object::BearerToken,
214        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
215        units: std::collections::BTreeSet<
216            super::super::super::objects::scout::units::api::UnitSymbol,
217        >,
218    ) -> Result<
219        std::collections::BTreeMap<
220            super::super::super::objects::scout::units::api::UnitSymbol,
221            super::super::super::objects::scout::units::api::Unit,
222        >,
223        conjure_http::private::Error,
224    >;
225    /// Returns the set of cataloged units that can be converted to and from the given unit.
226    /// No commensurable units does not imply the unit is invalid. Use /get-unit to check for validity.
227    #[endpoint(
228        method = POST,
229        path = "/units/v1/units/commensurable-units",
230        name = "getCommensurableUnits",
231        produces = conjure_http::server::conjure::CollectionResponseSerializer
232    )]
233    async fn get_commensurable_units(
234        &self,
235        #[auth]
236        auth_: conjure_object::BearerToken,
237        #[body(deserializer = conjure_http::server::StdRequestDeserializer)]
238        unit: super::super::super::objects::scout::units::api::UnitSymbol,
239    ) -> Result<
240        std::collections::BTreeSet<
241            super::super::super::objects::scout::units::api::Unit,
242        >,
243        conjure_http::private::Error,
244    >;
245}