Skip to content

Commit c29e3f7

Browse files
authored
paramerize pipeline on format
1 parent 65b9317 commit c29e3f7

File tree

15 files changed

+136
-118
lines changed

15 files changed

+136
-118
lines changed

sdk/core/azure_core/src/http/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ pub use response::Response;
2121

2222
pub use typespec_client_core::http::response;
2323
pub use typespec_client_core::http::{
24-
new_http_client, AppendToUrlQuery, Context, HttpClient, Method, StatusCode, Url,
24+
new_http_client, AppendToUrlQuery, Context, Format, HttpClient, JsonFormat, Method, StatusCode,
25+
Url,
2526
};
27+
28+
#[cfg(feature = "xml")]
29+
pub use typespec_client_core::http::XmlFormat;

sdk/core/azure_core/src/http/pipeline.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
ops::Deref,
99
sync::Arc,
1010
};
11-
use typespec_client_core::http::{self, policies::Policy};
11+
use typespec_client_core::http::{self, policies::Policy, Format, JsonFormat};
1212

1313
/// Execution pipeline.
1414
///
@@ -34,14 +34,17 @@ use typespec_client_core::http::{self, policies::Policy};
3434
/// cannot be enforced by code). All policies except Transport policy can assume there is another following policy (so
3535
/// `self.pipeline[0]` is always valid).
3636
#[derive(Debug, Clone)]
37-
pub struct Pipeline(http::Pipeline);
37+
pub struct Pipeline<F: Format = JsonFormat>(http::Pipeline<F>);
3838

39-
impl Pipeline {
39+
impl<F: Format> Pipeline<F> {
4040
/// Creates a new pipeline given the client library crate name and version,
4141
/// alone with user-specified and client library-specified policies.
4242
///
4343
/// Crates can simply pass `option_env!("CARGO_PKG_NAME")` and `option_env!("CARGO_PKG_VERSION")` for the
4444
/// `crate_name` and `crate_version` arguments respectively.
45+
///
46+
/// In addition, this constructor allows for specifying the response format (e.g. JSON, XML) to be used
47+
/// when deserializing the response body.
4548
pub fn new(
4649
crate_name: Option<&'static str>,
4750
crate_version: Option<&'static str>,
@@ -75,8 +78,8 @@ impl Pipeline {
7578
}
7679

7780
// TODO: Should we instead use the newtype pattern?
78-
impl Deref for Pipeline {
79-
type Target = http::Pipeline;
81+
impl<F: Format> Deref for Pipeline<F> {
82+
type Target = http::Pipeline<F>;
8083
fn deref(&self) -> &Self::Target {
8184
&self.0
8285
}

sdk/storage/azure_storage_blob/src/clients/blob_client.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use azure_core::{
2525
Bytes, Result,
2626
};
2727
use std::sync::Arc;
28+
use typespec_client_core::http::XmlFormat;
2829

2930
/// A client to interact with a specific Azure storage blob, although that blob may not yet exist.
3031
pub struct BlobClient {
@@ -114,7 +115,7 @@ impl BlobClient {
114115
pub async fn get_properties(
115116
&self,
116117
options: Option<BlobClientGetPropertiesOptions<'_>>,
117-
) -> Result<Response<BlobClientGetPropertiesResult>> {
118+
) -> Result<Response<BlobClientGetPropertiesResult, XmlFormat>> {
118119
self.client.get_properties(options).await
119120
}
120121

@@ -126,7 +127,7 @@ impl BlobClient {
126127
pub async fn set_properties(
127128
&self,
128129
options: Option<BlobClientSetPropertiesOptions<'_>>,
129-
) -> Result<Response<()>> {
130+
) -> Result<Response<(), XmlFormat>> {
130131
self.client.set_properties(options).await
131132
}
132133

@@ -136,7 +137,7 @@ impl BlobClient {
136137
pub async fn download(
137138
&self,
138139
options: Option<BlobClientDownloadOptions<'_>>,
139-
) -> Result<Response<BlobClientDownloadResult>> {
140+
) -> Result<Response<BlobClientDownloadResult, XmlFormat>> {
140141
self.client.download(options).await
141142
}
142143

@@ -155,7 +156,7 @@ impl BlobClient {
155156
overwrite: bool,
156157
content_length: u64,
157158
options: Option<BlockBlobClientUploadOptions<'_>>,
158-
) -> Result<Response<BlockBlobClientUploadResult>> {
159+
) -> Result<Response<BlockBlobClientUploadResult, XmlFormat>> {
159160
let mut options = options.unwrap_or_default();
160161

161162
if !overwrite {
@@ -179,7 +180,7 @@ impl BlobClient {
179180
pub async fn set_metadata(
180181
&self,
181182
options: Option<BlobClientSetMetadataOptions<'_>>,
182-
) -> Result<Response<()>> {
183+
) -> Result<Response<(), XmlFormat>> {
183184
self.client.set_metadata(options).await
184185
}
185186

@@ -191,7 +192,7 @@ impl BlobClient {
191192
pub async fn delete(
192193
&self,
193194
options: Option<BlobClientDeleteOptions<'_>>,
194-
) -> Result<Response<()>> {
195+
) -> Result<Response<(), XmlFormat>> {
195196
self.client.delete(options).await
196197
}
197198

@@ -206,7 +207,7 @@ impl BlobClient {
206207
&self,
207208
tier: AccessTier,
208209
options: Option<BlobClientSetTierOptions<'_>>,
209-
) -> Result<Response<()>> {
210+
) -> Result<Response<(), XmlFormat>> {
210211
self.client.set_tier(tier, options).await
211212
}
212213
}

sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use azure_core::{
1717
Result,
1818
};
1919
use std::sync::Arc;
20+
use typespec_client_core::http::XmlFormat;
2021

2122
/// A client to interact with a specified Azure storage container.
2223
pub struct BlobContainerClient {
@@ -99,7 +100,7 @@ impl BlobContainerClient {
99100
pub async fn create_container(
100101
&self,
101102
options: Option<BlobContainerClientCreateOptions<'_>>,
102-
) -> Result<Response<()>> {
103+
) -> Result<Response<(), XmlFormat>> {
103104
self.client.create(options).await
104105
}
105106

@@ -113,7 +114,7 @@ impl BlobContainerClient {
113114
pub async fn set_metadata(
114115
&self,
115116
options: Option<BlobContainerClientSetMetadataOptions<'_>>,
116-
) -> Result<Response<()>> {
117+
) -> Result<Response<(), XmlFormat>> {
117118
self.client.set_metadata(options).await
118119
}
119120

@@ -125,7 +126,7 @@ impl BlobContainerClient {
125126
pub async fn delete_container(
126127
&self,
127128
options: Option<BlobContainerClientDeleteOptions<'_>>,
128-
) -> Result<Response<()>> {
129+
) -> Result<Response<(), XmlFormat>> {
129130
self.client.delete(options).await
130131
}
131132

@@ -138,7 +139,7 @@ impl BlobContainerClient {
138139
pub async fn get_properties(
139140
&self,
140141
options: Option<BlobContainerClientGetPropertiesOptions<'_>>,
141-
) -> Result<Response<BlobContainerClientGetPropertiesResult>> {
142+
) -> Result<Response<BlobContainerClientGetPropertiesResult, XmlFormat>> {
142143
self.client.get_properties(options).await
143144
}
144145
}

sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl BlockBlobClient {
105105
&self,
106106
blocks: RequestContent<BlockLookupList>,
107107
options: Option<BlockBlobClientCommitBlockListOptions<'_>>,
108-
) -> Result<Response<BlockBlobClientCommitBlockListResult>> {
108+
) -> Result<Response<BlockBlobClientCommitBlockListResult, XmlFormat>> {
109109
self.client.commit_block_list(blocks, options).await
110110
}
111111

@@ -124,7 +124,7 @@ impl BlockBlobClient {
124124
content_length: u64,
125125
body: RequestContent<Bytes>,
126126
options: Option<BlockBlobClientStageBlockOptions<'_>>,
127-
) -> Result<Response<BlockBlobClientStageBlockResult>> {
127+
) -> Result<Response<BlockBlobClientStageBlockResult, XmlFormat>> {
128128
self.client
129129
.stage_block(block_id, content_length, body, options)
130130
.await

sdk/storage/azure_storage_blob/src/generated/clients/append_blob_client.rs

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)