Skip to content

Commit

Permalink
docs: update docstring/type hints for DetailedResponse class (#149)
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Adams <[email protected]>
  • Loading branch information
padamstx authored Aug 3, 2022
1 parent a9df521 commit b0dfd8e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions ibm_cloud_sdk_core/detailed_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

import json
from typing import Dict, Optional
from typing import Dict, Optional, Union

import requests

Expand All @@ -29,41 +29,44 @@ class DetailedResponse:
status_code: The status code of there response, defaults to None.
Attributes:
response (requests.Response): The response to the service request.
result (dict, requests.Response, None): The response to the service request.
headers (dict): The headers of the response.
status_code (int): The status code of the response.
"""
def __init__(self,
*,
response: Optional[requests.Response] = None,
response: Optional[Union[dict, requests.Response]] = None,
headers: Optional[Dict[str, str]] = None,
status_code: Optional[int] = None) -> None:
self.result = response
self.headers = headers
self.status_code = status_code

def get_result(self) -> requests.Response:
"""Get the HTTP response of the service request.
def get_result(self) -> Optional[Union[dict, requests.Response]]:
"""Get the response returned by the service request.
Returns:
The response to the service request
The response to the service request. This could be one of the following:
1. a dict that represents an instance of a response model
2. a requests.Response instance if the operation returns a streamed response
3. None if the server returned no response body
"""
return self.result

def get_headers(self) -> dict:
def get_headers(self) -> Optional[dict]:
"""The HTTP response headers of the service request.
Returns:
A dictionary of response headers
A dictionary of response headers or None if no headers are present.
"""
return self.headers

def get_status_code(self) -> int:
"""The HTTP status code of the service request.
Returns:
The status code of the service request.
The status code associated with the service request.
"""
return self.status_code

Expand Down

0 comments on commit b0dfd8e

Please sign in to comment.