Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public response when no response type defined #1349

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

dav1do
Copy link
Contributor

@dav1do dav1do commented Aug 31, 2023

Fixes #1348. We want access to the internal response in all cases. It was skipped when a response type wasn't defined in the schema.

Now the generated code includes the following impl Response when there are no headers:

    // azure-sdk-for-rust/services/mgmt/compute/src/package_2022_11_01/mod.rs
    pub mod power_off {
        use super::models;
        pub struct Response(azure_core::Response);
        impl Response {
            pub fn into_raw_response(self) -> azure_core::Response {
                self.0
            }
            pub fn as_raw_response(&self) -> &azure_core::Response {
                &self.0
            }
        }
        impl From<Response> for azure_core::Response {
            fn from(rsp: Response) -> Self {
                rsp.into_raw_response()
            }
        }
        impl AsRef<azure_core::Response> for Response {
            fn as_ref(&self) -> &azure_core::Response {
                self.as_raw_response()
            }
        }
    }

and if there are headers, they are included as well:

    // azure-sdk-for-rust/services/mgmt/alertsmanagement/src/package_preview_2021_08/mod.rs
    pub mod delete {
        use super::models;
        pub struct Response(azure_core::Response);
        impl Response {
            pub fn into_raw_response(self) -> azure_core::Response {
                self.0
            }
            pub fn as_raw_response(&self) -> &azure_core::Response {
                &self.0
            }
            pub fn headers(&self) -> Headers {
                Headers(self.0.headers())
            }
        }
        impl From<Response> for azure_core::Response {
            fn from(rsp: Response) -> Self {
                rsp.into_raw_response()
            }
        }
        impl AsRef<azure_core::Response> for Response {
            fn as_ref(&self) -> &azure_core::Response {
                self.as_raw_response()
            }
        }
        pub struct Headers<'a>(&'a azure_core::headers::Headers);
        impl<'a> Headers<'a> {
            #[doc = "Service generated Request ID."]
            pub fn x_ms_request_id(&self) -> azure_core::Result<&str> {
                self.0.get_str(&azure_core::headers::HeaderName::from_static("x-ms-request-id"))
            }
        }
    }

I updated the changelog, even though I'm not generating a new version. I was able to generate updated SDKs locally after adding package-2023-09-01-preview to /svc/devcenter/autorust.toml and removing the quota spec.

Let me know if there's something I can do to help with publishing or if I missed anything. I plan to generate the compute for myself and use a patched version.

We want access to the internal response in all cases.
It was skipped without a response type defined in the schema.
@dav1do
Copy link
Contributor Author

dav1do commented Aug 31, 2023

@microsoft-github-policy-service agree

@heaths heaths requested a review from cataggar August 31, 2023 14:33
@demoray demoray merged commit 84b192d into Azure:main Sep 5, 2023
16 checks passed
demoray pushed a commit to demoray/azure-sdk-for-rust that referenced this pull request Sep 5, 2023
Regenerate services with Azure#1349 applied.  This uses the same revision of the Azure REST API specs used during the last release of the Azure SDK for Rust.

Ref: Azure/azure-rest-api-specs@d99f18b
demoray added a commit that referenced this pull request Sep 5, 2023
Regenerate services with #1349 applied.  This uses the same revision of the Azure REST API specs used during the last release of the Azure SDK for Rust.

Ref: Azure/azure-rest-api-specs@d99f18b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants