forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#264 from Azure/ServiceResponseWithHeaders
Add RestResponse classes
- Loading branch information
Showing
8 changed files
with
304 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
client-runtime/src/main/java/com/microsoft/rest/RestResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.rest; | ||
|
||
/** | ||
* The response object that is a result of making a REST request. | ||
* @param <THeaders> The deserialized type of the response headers. | ||
*/ | ||
public class RestResponse<THeaders> { | ||
private final int statusCode; | ||
private final THeaders headers; | ||
|
||
/** | ||
* Create a new RestResponse object. | ||
* @param statusCode The status code of the HTTP response. | ||
* @param headers The deserialized headers of the HTTP response. | ||
*/ | ||
public RestResponse(int statusCode, THeaders headers) { | ||
this.statusCode = statusCode; | ||
this.headers = headers; | ||
} | ||
|
||
/** | ||
* The status code of the HTTP response. | ||
* @return The status code of the HTTP response. | ||
*/ | ||
public int statusCode() { | ||
return statusCode; | ||
} | ||
|
||
/** | ||
* The deserialized headers of the HTTP response. | ||
* @return The deserialized headers of the HTTP response. | ||
*/ | ||
public THeaders headers() { | ||
return headers; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
client-runtime/src/main/java/com/microsoft/rest/RestResponseWithBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.rest; | ||
|
||
/** | ||
* The REST response object that is a result of making a REST request. | ||
* @param <TBody> The deserialized type of the response body. | ||
* @param <THeaders> The deserialized type of the response headers. | ||
*/ | ||
public class RestResponseWithBody<THeaders, TBody> extends RestResponse<THeaders> { | ||
private final TBody body; | ||
|
||
/** | ||
* Create a new RestResponseWithBody object. | ||
* @param statusCode The status code for the REST response. | ||
* @param headers The deserialized headers. | ||
* @param body The deserialized body. | ||
*/ | ||
public RestResponseWithBody(int statusCode, THeaders headers, TBody body) { | ||
super(statusCode, headers); | ||
|
||
this.body = body; | ||
} | ||
|
||
/** | ||
* The deserialized body of the HTTP response. | ||
* @return The deserialized body of the HTTP response. | ||
*/ | ||
public TBody body() { | ||
return body; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
client-runtime/src/test/java/com/microsoft/rest/HttpBinHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
* | ||
* Code generated by Microsoft (R) AutoRest Code Generator. | ||
*/ | ||
|
||
package com.microsoft.rest; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Defines headers for httpbin.org operations. | ||
*/ | ||
public class HttpBinHeaders { | ||
@JsonProperty(value = "Date") | ||
public DateTimeRfc1123 date; | ||
|
||
@JsonProperty(value = "Via") | ||
public String via; | ||
|
||
@JsonProperty(value = "Connection") | ||
public String connection; | ||
|
||
@JsonProperty(value = "X-Processed-Time") | ||
public double xProcessedTime; | ||
|
||
@JsonProperty(value = "Access-Control-Allow-Credentials") | ||
public boolean accessControlAllowCredentials; | ||
} |
Oops, something went wrong.