ServiceClient Class

REST Service Client. Maintains client pipeline and handles all requests and responses.

Inheritance
msrest.service_client._ServiceClientCore
ServiceClient

Constructor

ServiceClient(creds: Any, config: Configuration)

Parameters

creds
Required

Deprecated, will be removed in next major version. Creds are now read from config.credentials.

config
Configuration
Required

Service configuration.

Methods

add_header

Add a persistent header - this header will be applied to all requests sent during the current client session.

Deprecated since version 0.5.0: Use config.headers instead

close

Close the pipeline if keep_alive is True.

send

Prepare and send request object according to configuration.

send_formdata

Send data as a multipart form-data request. We only deal with file-like objects or strings at this point. The requests is not yet streamed.

This method is deprecated, and shouldn't be used anymore.

stream_download

Generator for streaming request body data.

add_header

Add a persistent header - this header will be applied to all requests sent during the current client session.

Deprecated since version 0.5.0: Use config.headers instead

add_header(header: str, value: str) -> None

Parameters

header
str
Required

The header name.

value
str
Required

The header value.

close

Close the pipeline if keep_alive is True.

close() -> None

send

Prepare and send request object according to configuration.

send(request, headers=None, content=None, **kwargs)

Parameters

request
<xref:ClientRequest>
Required

The request object to be sent.

headers
dict
default value: None

Any headers to add to the request.

content
default value: None

Any body data to add to the request.

config
Required

Any specific config overrides

send_formdata

Send data as a multipart form-data request. We only deal with file-like objects or strings at this point. The requests is not yet streamed.

This method is deprecated, and shouldn't be used anymore.

send_formdata(request, headers=None, content=None, **config)

Parameters

request
<xref:ClientRequest>
Required

The request object to be sent.

headers
dict
default value: None

Any headers to add to the request.

content
dict
default value: None

Dictionary of the fields of the formdata.

config
Required

Any specific config overrides.

stream_download

Generator for streaming request body data.

stream_download(data: Union[requests.Response, ClientResponse], callback: Callable) -> Iterator[bytes]

Parameters

data
Required

A response object to be streamed.

callback
Required

Custom callback for monitoring progress.