PipelineClient Class

Service client core methods.

Builds a Pipeline client.

Inheritance
azure.core.pipeline.transport._base.PipelineClientBase
PipelineClient
PipelineClient

Constructor

PipelineClient(base_url: str, *, pipeline: Pipeline[HTTPRequestType, HTTPResponseType] | None = None, config: Configuration[HTTPRequestType, HTTPResponseType] | None = None, **kwargs: Any)

Parameters

Name Description
base_url
Required
str

URL for the request.

Keyword-Only Parameters

Name Description
config

If omitted, the standard configuration is used.

pipeline

If omitted, a Pipeline object is created and returned.

policies

If omitted, the standard policies of the configuration object is used.

per_call_policies

If specified, the policies will be added into the policy list before RetryPolicy

per_retry_policies

If specified, the policies will be added into the policy list after RetryPolicy

transport

If omitted, RequestsTransport is used for synchronous transport.

Examples

Builds the pipeline client.


   from azure.core import PipelineClient
   from azure.core.rest import HttpRequest
   from azure.core.pipeline.policies import RedirectPolicy, UserAgentPolicy

   # example configuration with some policies
   policies: Iterable[Union[HTTPPolicy, SansIOHTTPPolicy]] = [UserAgentPolicy("myuseragent"), RedirectPolicy()]

   client: PipelineClient[HttpRequest, HttpResponse] = PipelineClient(base_url=url, policies=policies)
   request = HttpRequest("GET", "https://bing.com")

   pipeline_response = client._pipeline.run(request)

Methods

close
delete

Create a DELETE request object.

format_url

Format request URL with the client base URL, unless the supplied URL is already absolute.

Note that both the base url and the template url can contain query parameters.

get

Create a GET request object.

head

Create a HEAD request object.

merge

Create a MERGE request object.

options

Create a OPTIONS request object.

patch

Create a PATCH request object.

post

Create a POST request object.

put

Create a PUT request object.

send_request

Method that runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

close

close() -> None

delete

Create a DELETE request object.

delete(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None

Returns

Type Description

An HttpRequest object

format_url

Format request URL with the client base URL, unless the supplied URL is already absolute.

Note that both the base url and the template url can contain query parameters.

format_url(url_template: str, **kwargs: Any) -> str

Parameters

Name Description
url_template
Required
str

The request URL to be formatted if necessary.

Returns

Type Description
str

The formatted URL.

get

Create a GET request object.

get(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None

Returns

Type Description

An HttpRequest object

head

Create a HEAD request object.

head(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None
stream_content
<xref:stream> or <xref:generator> or <xref:asyncgenerator>

The body content as a stream

Default value: None

Returns

Type Description

An HttpRequest object

merge

Create a MERGE request object.

merge(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None

Returns

Type Description

An HttpRequest object

options

Create a OPTIONS request object.

options(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, *, content: bytes | str | Dict[Any, Any] | None = None, form_content: Dict[Any, Any] | None = None, **kwargs: Any) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None

Keyword-Only Parameters

Name Description
content

The body content

form_content

Form content

Returns

Type Description

An HttpRequest object

patch

Create a PATCH request object.

patch(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None
stream_content
<xref:stream> or <xref:generator> or <xref:asyncgenerator>

The body content as a stream

Default value: None

Returns

Type Description

An HttpRequest object

post

Create a POST request object.

post(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None
stream_content
<xref:stream> or <xref:generator> or <xref:asyncgenerator>

The body content as a stream

Default value: None

Returns

Type Description

An HttpRequest object

put

Create a PUT request object.

put(url: str, params: Dict[str, str] | None = None, headers: Dict[str, str] | None = None, content: Any = None, form_content: Dict[str, Any] | None = None, stream_content: Any = None) -> HttpRequest

Parameters

Name Description
url
Required
str

The request URL.

params

Request URL parameters.

Default value: None
headers

Headers

Default value: None
content
bytes or str or dict

The body content

Default value: None
form_content

Form content

Default value: None
stream_content
<xref:stream> or <xref:generator> or <xref:asyncgenerator>

The body content as a stream

Default value: None

Returns

Type Description

An HttpRequest object

send_request

Method that runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
send_request(request: HTTPRequestType, *, stream: bool = False, **kwargs: Any) -> HTTPResponseType

Parameters

Name Description
request
Required

The network request you want to make. Required.

Keyword-Only Parameters

Name Description
stream

Whether the response payload will be streamed. Defaults to False.

Returns

Type Description

The response of your network call. Does not do error handling on your response.