Skip to content

Commit 765da71

Browse files
authored
Rename "operation" to "poller" (Azure#2403)
1 parent a2d15c9 commit 765da71

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

sdk/core/azure_core/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
- Removed `query_param` module.
5050
- Removed `RequestId` type alias from root.
5151
- Removed `SessionToken` type alias from root.
52-
- Renamed `lro` module to `http::operation` module.
52+
- Renamed `lro` module to `http::poller` module.
53+
- Renamed `lro` module types with prefix "Lro" to prefix "Poller".
5354
- Renamed `tokio` module to `fs` since it contained only the `typespec_client_core::fs` module members.
5455

5556
### Bugs Fixed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
66
pub mod headers;
77
mod models;
8-
pub mod operation;
98
mod options;
109
mod pager;
1110
mod pipeline;
1211
pub mod policies;
12+
pub mod poller;
1313
pub mod request;
1414

1515
pub use models::*;
Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ const DEFAULT_RETRY_TIME: Duration = Duration::from_secs(30);
1515

1616
/// Long-Running Operation (LRO) status.
1717
#[derive(Debug)]
18-
pub enum OperationStatus {
18+
pub enum PollerStatus {
1919
InProgress,
2020
Succeeded,
2121
Failed,
2222
Canceled,
2323
Other(String),
2424
}
2525

26-
impl From<&str> for OperationStatus {
26+
impl From<&str> for PollerStatus {
2727
fn from(s: &str) -> Self {
2828
match s {
29-
"InProgress" => OperationStatus::InProgress,
30-
"Succeeded" => OperationStatus::Succeeded,
31-
"Failed" => OperationStatus::Failed,
29+
"InProgress" => PollerStatus::InProgress,
30+
"Succeeded" => PollerStatus::Succeeded,
31+
"Failed" => PollerStatus::Failed,
3232
// While the specification indicates we should use `Canceled`, in
3333
// practice numerous services use `Cancelled`. As such, we support
3434
// both.
3535
//
3636
// Ref: <https://github.com/Azure/azure-resource-manager-rpc/issues/144>
37-
"Canceled" | "Cancelled" => OperationStatus::Canceled,
38-
_ => OperationStatus::Other(s.to_owned()),
37+
"Canceled" | "Cancelled" => PollerStatus::Canceled,
38+
_ => PollerStatus::Other(s.to_owned()),
3939
}
4040
}
4141
}
@@ -51,7 +51,7 @@ pub mod location {
5151
use crate::{
5252
http::{
5353
headers::{Headers, AZURE_ASYNCOPERATION, LOCATION, OPERATION_LOCATION},
54-
operation::OperationStatus,
54+
poller::PollerStatus,
5555
Url,
5656
},
5757
json::from_json,
@@ -79,40 +79,37 @@ pub mod location {
7979
}
8080
}
8181

82-
/// Get the [`OperationStatus`] from the response body.
83-
pub fn get_operation_state(body: &[u8]) -> Option<OperationStatus> {
82+
/// Get the [`PollerStatus`] from the response body.
83+
pub fn get_operation_state(body: &[u8]) -> Option<PollerStatus> {
8484
#[derive(serde::Deserialize)]
8585
struct Body {
8686
status: String,
8787
}
8888
let body: Body = from_json(body).ok()?;
89-
Some(OperationStatus::from(body.status.as_str()))
89+
Some(PollerStatus::from(body.status.as_str()))
9090
}
9191
}
9292

9393
/// Types and methods for getting operation status from the body.
9494
pub mod body_content {
95-
use crate::http::{operation::OperationStatus, StatusCode};
95+
use crate::http::{poller::PollerStatus, StatusCode};
9696
use crate::json::{from_json, to_json};
9797
use serde::{Deserialize, Serialize};
9898

9999
/// Extract the Long-Running Operation (LRO) state based on the status code and response body.
100-
pub fn get_operation_state<S>(
101-
status_code: StatusCode,
102-
body: &S,
103-
) -> crate::Result<OperationStatus>
100+
pub fn get_operation_state<S>(status_code: StatusCode, body: &S) -> crate::Result<PollerStatus>
104101
where
105102
S: Serialize,
106103
{
107104
match status_code {
108-
StatusCode::Accepted => Ok(OperationStatus::InProgress),
105+
StatusCode::Accepted => Ok(PollerStatus::InProgress),
109106
StatusCode::Created => {
110-
Ok(get_provisioning_state_from_body(body).unwrap_or(OperationStatus::InProgress))
107+
Ok(get_provisioning_state_from_body(body).unwrap_or(PollerStatus::InProgress))
111108
}
112109
StatusCode::Ok => {
113-
Ok(get_provisioning_state_from_body(body).unwrap_or(OperationStatus::Succeeded))
110+
Ok(get_provisioning_state_from_body(body).unwrap_or(PollerStatus::Succeeded))
114111
}
115-
StatusCode::NoContent => Ok(OperationStatus::Succeeded),
112+
StatusCode::NoContent => Ok(PollerStatus::Succeeded),
116113
_ => Err(crate::error::Error::from(
117114
crate::error::ErrorKind::HttpResponse {
118115
status: status_code,
@@ -133,12 +130,12 @@ pub mod body_content {
133130
properties: Properties,
134131
}
135132

136-
fn get_provisioning_state_from_body<S>(body: &S) -> Option<OperationStatus>
133+
fn get_provisioning_state_from_body<S>(body: &S) -> Option<PollerStatus>
137134
where
138135
S: Serialize,
139136
{
140137
let body: Body = from_json(to_json(&body).ok()?).ok()?;
141-
Some(OperationStatus::from(
138+
Some(PollerStatus::from(
142139
body.properties.provisioning_state.as_str(),
143140
))
144141
}

0 commit comments

Comments
 (0)