Service client core methods.
Builds an AsyncPipeline client.
base_url (str) â URL for the request.
config (Configuration) â If omitted, the standard configuration is used.
pipeline (Pipeline) â If omitted, a Pipeline object is created and returned.
policies (list[AsyncHTTPPolicy]) â If omitted, the standard policies of the configuration object is used.
per_call_policies (Union[AsyncHTTPPolicy, SansIOHTTPPolicy, list[AsyncHTTPPolicy], list[SansIOHTTPPolicy]]) â If specified, the policies will be added into the policy list before RetryPolicy
per_retry_policies (Union[AsyncHTTPPolicy, SansIOHTTPPolicy, list[AsyncHTTPPolicy], list[SansIOHTTPPolicy]]) â If specified, the policies will be added into the policy list after RetryPolicy
transport (AsyncHttpTransport) â If omitted, AioHttpTransport is used for asynchronous transport.
An async pipeline object.
Example:
Builds the async pipeline client.ïfrom azure.core import AsyncPipelineClient from azure.core.pipeline.policies import AsyncRedirectPolicy, UserAgentPolicy from azure.core.rest import HttpRequest # example policies request = HttpRequest("GET", url) policies: Iterable[Union[AsyncHTTPPolicy, SansIOHTTPPolicy]] = [ UserAgentPolicy("myuseragent"), AsyncRedirectPolicy(), ] async with AsyncPipelineClient[HttpRequest, AsyncHttpResponse](base_url=url, policies=policies) as client: response = await client.send_request(request)
Create a DELETE request object.
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.
Create a GET request object.
Create a HEAD request object.
An HttpRequest object
Create a MERGE request object.
Create a OPTIONS request object.
content â The body content
form_content (dict) â Form content
An HttpRequest object
Create a PATCH request object.
An HttpRequest object
Create a POST request object.
An HttpRequest object
Create a PUT request object.
An HttpRequest object
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 = await client.send_request(request) <AsyncHttpResponse: 200 OK>
request (HttpRequest) â The network request you want to make. Required.
stream (bool) â Whether the response payload will be streamed. Defaults to False.
The response of your network call. Does not do error handling on your response.
An enum to describe Azure Cloud.
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
Return a version of the string suitable for caseless comparisons.
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
Return the number of non-overlapping occurrences of substring sub in string S[start:end].
Optional arguments start and end are interpreted as in slice notation.
Encode the string using the codec registered for encoding.
The encoding in which to encode the string.
The error handling scheme to use for encoding errors. The default is âstrictâ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are âignoreâ, âreplaceâ and âxmlcharrefreplaceâ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
Return True if the string ends with the specified suffix, False otherwise.
A string or a tuple of strings to try.
Optional start position. Default: start of the string.
Optional stop position. Default: end of the string.
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].
Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.
Return a formatted version of the string, using substitutions from args and kwargs. The substitutions are identified by braces (â{â and â}â).
Return a formatted version of the string, using substitutions from mapping. The substitutions are identified by braces (â{â and â}â).
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].
Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as âdefâ or âclassâ.
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
Return True if all characters in the string are printable, False otherwise.
A character is printable if repr() may use it in its output.
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: â.â.join([âabâ, âpqâ, ârsâ]) -> âab.pq.rsâ
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
Return a copy of the string converted to lowercase.
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
Return a copy with all occurrences of substring old replaced by new.
- count
Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
Return True if the string starts with the specified prefix, False otherwise.
A string or a tuple of strings to try.
Optional start position. Default: start of the string.
Optional stop position. Default: end of the string.
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Convert uppercase characters to lowercase and lowercase characters to uppercase.
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
Replace each character in the string using the given translation table.
- table
Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
Return a copy of the string converted to uppercase.
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
Azure China cloud
Azure public cloud
Azure US government cloud
Enum metaclass to allow for interoperability with case-insensitive strings.
Consuming this metaclass in an SDK should be done in the following manner:
from enum import Enum from azure.core import CaseInsensitiveEnumMeta class MyCustomEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): FOO = 'foo' BAR = 'bar'
Return a typeâs method resolution order.
An enum to describe match conditions.
If the target object does not exist. Usually it maps to etag!=â*â
Only if the target object is modified. Usually it maps to etag!=<specific etag>
If the target object is not modified. Usually it maps to etag=<specific etag>
If the target object exists. Usually it maps to etag=â*â
Matches any condition
Service client core methods.
Builds a Pipeline client.
base_url (str) â URL for the request.
config (Configuration) â If omitted, the standard configuration is used.
pipeline (Pipeline) â If omitted, a Pipeline object is created and returned.
policies (list[HTTPPolicy]) â If omitted, the standard policies of the configuration object is used.
per_call_policies (Union[HTTPPolicy, SansIOHTTPPolicy, list[HTTPPolicy], list[SansIOHTTPPolicy]]) â If specified, the policies will be added into the policy list before RetryPolicy
per_retry_policies (Union[HTTPPolicy, SansIOHTTPPolicy, list[HTTPPolicy], list[SansIOHTTPPolicy]]) â If specified, the policies will be added into the policy list after RetryPolicy
transport (HttpTransport) â If omitted, RequestsTransport is used for synchronous transport.
A pipeline object.
Example:
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)
Create a DELETE request object.
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.
Create a GET request object.
Create a HEAD request object.
An HttpRequest object
Create a MERGE request object.
Create a OPTIONS request object.
content â The body content
form_content (dict) â Form content
An HttpRequest object
Create a PATCH request object.
An HttpRequest object
Create a POST request object.
An HttpRequest object
Create a PUT request object.
An HttpRequest object
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>
request (HttpRequest) â The network request you want to make. Required.
stream (bool) â Whether the response payload will be streamed. Defaults to False.
The response of your network call. Does not do error handling on your response.
Return an async iterator of items.
args and kwargs will be passed to the AsyncPageIterator constructor directly, except page_iterator_class
Get an async iterator of pages of objects, instead of an async iterator of objects.
continuation_token (str) â An opaque continuation token. This value can be retrieved from the continuation_token field of a previous generator object. If specified, this generator will begin returning results from this point.
An async iterator of pages (themselves async iterator of objects)
AsyncIterator[AsyncIterator[ReturnType]]
Return an async iterator of pages.
get_next â Callable that take the continuation token and return a HTTP response
extract_data â Callable that take an HTTP response and return a tuple continuation token, list of ReturnType
continuation_token (str) â The continuation token needed by get_next
Represents an OAuth access token.
Create new instance of AccessToken(token, expires_on)
Return number of occurrences of value.
Return first index of value.
Raises ValueError if the value is not present.
The tokenâs expiration time in Unix time.
The token string.
Information about an OAuth access token.
This class is an alternative to AccessToken which provides additional information about the token.
The tokenâs expiration time in Unix time.
Specifies the time, in Unix time, when the cached token should be proactively refreshed. Optional.
The token string.
The type of access token.
Credential type used for authenticating to an Azure service. It provides the ability to update the key without creating a new client.
key (str) â The key used to authenticate to an Azure service
TypeError â If the key is not a string.
Update the key.
This can be used when youâve regenerated your service key and want to update long-lived clients.
key (str) â The key used to authenticate to an Azure service
ValueError or TypeError â If the key is None, empty, or not a string.
The value of the configured key.
The value of the configured key.
Credential type used for working with any service needing a named key that follows patterns established by the other credential types.
TypeError â If the name or key is not a string.
Update the named key credential.
Both name and key must be provided in order to update the named key credential. Individual attributes cannot be updated.
The value of the configured name.
AzureNamedKey
The value of the configured name.
Credential type used for authenticating to an Azure service. It provides the ability to update the shared access signature without creating a new client.
signature (str) â The shared access signature used to authenticate to an Azure service
TypeError â If the signature is not a string.
Update the shared access signature.
This can be used when youâve regenerated your shared access signature and want to update long-lived clients.
signature (str) â The shared access signature used to authenticate to an Azure service
ValueError â If the signature is None or empty.
TypeError â If the signature is not a string.
The value of the configured shared access signature.
The value of the configured shared access signature.
Protocol for classes able to provide OAuth access tokens with additional properties.
Close the credential, releasing any resources it holds.
None
None
Request an access token for scopes.
This is an alternative to get_token to enable certain scenarios that require additional properties on the token.
scopes (str) â The type of access needed.
options (TokenRequestOptions) â A dictionary of options for the token request. Unknown options will be ignored. Optional.
An AccessTokenInfo instance containing information about the token.
Protocol for classes able to provide OAuth tokens.
Request an access token for scopes.
scopes (str) â The type of access needed.
claims (str) â Additional claims required in the token, such as those returned in a resource providerâs claims challenge following an authorization failure.
tenant_id (str) â Optional tenant to include in the token request.
enable_cae (bool) â Indicates whether to enable Continuous Access Evaluation (CAE) for the requested token. Defaults to False.
An AccessToken instance containing the token string and its expiration time in Unix time.
Options to use for access token requests. All parameters are optional.
Remove all items from the dict.
Return a shallow copy of the dict.
Create a new dictionary with keys from iterable and values set to value.
Return the value for key if key is in the dictionary, else default.
Return a set-like object providing a view on the dictâs items.
Return a set-like object providing a view on the dictâs keys.
If the key is not found, return the default if given; otherwise, raise a KeyError.
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
Return an object providing a view on the dictâs values.
Additional claims required in the token, such as those returned in a resource providerâs claims challenge following an authorization failure.
Indicates whether to enable Continuous Access Evaluation (CAE) for the requested token.
The tenant ID to include in the token request.
Protocol for classes able to provide OAuth access tokens with additional properties.
Close the credential, releasing any resources.
None
None
Request an access token for scopes.
This is an alternative to get_token to enable certain scenarios that require additional properties on the token.
scopes (str) â The type of access needed.
options (TokenRequestOptions) â A dictionary of options for the token request. Unknown options will be ignored. Optional.
An AccessTokenInfo instance containing the token string and its expiration time in Unix time.
Protocol for classes able to provide OAuth tokens.
Close the credential, releasing any resources.
None
None
Request an access token for scopes.
scopes (str) â The type of access needed.
claims (str) â Additional claims required in the token, such as those returned in a resource providerâs claims challenge following an authorization failure.
tenant_id (str) â Optional tenant to include in the token request.
enable_cae (bool) â Indicates whether to enable Continuous Access Evaluation (CAE) for the requested token. Defaults to False.
An AccessToken instance containing the token string and its expiration time in Unix time.
Base exception for all errors.
message (object) â The message object stringified as âmessageâ attribute
error (Exception) â The original exception if any
inner_exception (Exception) â The exception passed with the âerrorâ kwarg
exc_type â The exc_type from sys.exc_info()
exc_value â The exc_value from sys.exc_info()
exc_traceback â The exc_traceback from sys.exc_info()
exc_msg â A string formatting of message parameter, exc_type and exc_value
message (str) â A stringified version of the message parameter
continuation_token (str) â A token reference to continue an incomplete operation. This value is optional and will be None where continuation is either unavailable or not applicable.
Raise the exception with the existing traceback.
Deprecated since version 1.22.0: This method is deprecated as we donât support Python 2 anymore. Use raise/from instead.
An error response with status code 4xx. This will not be raised directly by the Azure core pipeline.
Error raised during response deserialization.
Raised if an error is encountered during deserialization.
A request was made, and a non-success status code was received from the service.
message (object) â The message object stringified as âmessageâ attribute
response (HttpResponse or AsyncHttpResponse) â The response that triggered the exception.
reason (str) â The HTTP response reason
status_code (int) â HttpResponseâs status code
response (HttpResponse or AsyncHttpResponse) â The response that triggered the exception.
model (Model) â The request body/response body model
error (ODataV4Format) â The formatted error
An HTTP response error where the JSON is decoded as OData V4 error format.
response (HttpResponse) â The response object.
odata_json (dict) â The parsed JSON body as attribute for convenience.
~.code (str) â Its value is a service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response.
message (str) â Human-readable, language-dependent representation of the error.
target (str) â The target of the particular error (for example, the name of the property in error). This field is optional and may be None.
details (list[ODataV4Format]) â Array of ODataV4Format instances that MUST contain name/value pairs for code and message, and MAY contain a name/value pair for target, as described above.
innererror (dict) â An object. The contents of this object are service-defined. Usually this object contains information that will help debug the service.
An error response with status code 4xx. This will not be raised directly by the Azure core pipeline.
An error response with status code 4xx, typically 412 Conflict. This will not be raised directly by the Azure core pipeline.
An error response, typically triggered by a 412 response (for update) or 404 (for get/post)
An error response with status code 304. This will not be raised directly by the Azure core pipeline.
Error thrown if you try to access a responseâs content without reading first.
It is thrown if you try to access an ~azure.core.rest.HttpResponse or ~azure.core.rest.AsyncHttpResponseâs content without first reading the responseâs bytes in first.
response (HttpResponse or AsyncHttpResponse) â The response that triggered the exception.
Raised if an error is encountered during serialization.
An error occurred while attempt to make a request to the service. No request was sent.
The request was sent, but the client failed to understand the response. The connection may have timed out. These errors can be retried for idempotent or safe operations
Error thrown if you try to access the stream of a response once closed.
It is thrown if you try to read / stream an ~azure.core.rest.HttpResponse or ~azure.core.rest.AsyncHttpResponse once the responseâs stream has been closed.
response (HttpResponse or AsyncHttpResponse) â The response that triggered the exception.
Error thrown if you try to access the stream of a response once consumed.
It is thrown if you try to read / stream an ~azure.core.rest.HttpResponse or ~azure.core.rest.AsyncHttpResponse once the responseâs stream has been consumed.
response (HttpResponse or AsyncHttpResponse) â The response that triggered the exception.
Reached the maximum number of redirect attempts.
history (list[RequestHistory]) â The history of requests made while trying to fulfill the request.
Class to describe OData V4 error format.
Example of JSON:
{ "error": { "code": "ValidationError", "message": "One or more fields contain incorrect values: ", "details": [ { "code": "ValidationError", "target": "representation", "message": "Parsing error(s): String '' does not match regex pattern '^[^{}/ :]+(?: :\\d+)?$'. Path 'host', line 1, position 297." }, { "code": "ValidationError", "target": "representation", "message": "Parsing error(s): The input OpenAPI file is not valid for the OpenAPI specificate https: //github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md (schema https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json)." } ] } }
json_object (dict) â A Python dict representing a ODataV4 JSON
~.code (str) â Its value is a service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response.
message (str) â Human-readable, language-dependent representation of the error.
target (str) â The target of the particular error (for example, the name of the property in error). This field is optional and may be None.
details (list[ODataV4Format]) â Array of ODataV4Format instances that MUST contain name/value pairs for code and message, and MAY contain a name/value pair for target, as described above.
innererror (dict) â An object. The contents of this object are service-defined. Usually this object contains information that will help debug the service.
Return a detailed string of the error.
A string with the details of the error.
Properties of the CloudEvent 1.0 Schema. All required parameters must be populated in order to send to Azure.
specversion (str) â Optional. The version of the CloudEvent spec. Defaults to â1.0â
data (object) â Optional. Event data specific to the event type.
time (datetime) â Optional. The time (in UTC) the event was generated.
dataschema (str) â Optional. Identifies the schema that data adheres to.
datacontenttype (str) â Optional. Content type of data value.
subject (str) â Optional. This describes the subject of the event in the context of the event producer (identified by source).
id (Optional[str]) â Optional. An identifier for the event. The combination of id and source must be unique for each distinct event. If not provided, a random UUID will be generated and used.
extensions (Optional[dict]) â Optional. A CloudEvent MAY include any number of additional context attributes with distinct names represented as key - value pairs. Each extension must be alphanumeric, lower cased and must not exceed the length of 20 characters.
Returns the deserialized CloudEvent object when a dict is provided.
event (dict) â The dict representation of the event which needs to be deserialized.
The deserialized CloudEvent object.
Returns the deserialized CloudEvent object when a json payload is provided.
event (object) â The json string that should be converted into a CloudEvent. This can also be a storage QueueMessage, eventhubâs EventData or ServiceBusMessage
The deserialized CloudEvent object.
ValueError â If the provided JSON is invalid.
Event data specific to the event type.
Content type of data value.
Identifies the schema that data adheres to.
A CloudEvent MAY include any number of additional context attributes with distinct names represented as key - value pairs. Each extension must be alphanumeric, lower cased and must not exceed the length of 20 characters.
An identifier for the event. The combination of id and source must be unique for each distinct event. If not provided, a random UUID will be generated and used.
Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. If publishing to a domain topic, source must be the domain topic name.
The version of the CloudEvent spec. Defaults to â1.0â
This describes the subject of the event in the context of the event producer (identified by source)
The time (in UTC) the event was generated.
Type of event related to the originating occurrence.
Return an iterator of items.
args and kwargs will be passed to the PageIterator constructor directly, except page_iterator_class
Get an iterator of pages of objects, instead of an iterator of objects.
continuation_token (str) â An opaque continuation token. This value can be retrieved from the continuation_token field of a previous generator object. If specified, this generator will begin returning results from this point.
An iterator of pages (themselves iterator of objects)
iterator[iterator[ReturnType]]
Get the next item in the iterator.
The next item in the iterator.
ReturnType
StopIteration â If there are no more items to return.
Return an iterator of pages.
get_next â Callable that take the continuation token and return a HTTP response
extract_data â Callable that take an HTTP response and return a tuple continuation token, list of ReturnType
continuation_token (str) â The continuation token needed by get_next
Get the next page in the iterator.
An iterator of objects in the next page.
iterator[ReturnType]
StopIteration â If there are no more pages to return.
AzureError â If the request fails.
Provide access to settings for globally used Azure configuration values.
Settings for globally used Azure configuration values.
You probably donât want to create an instance of this class, but call the singleton instance:
from azure.core.settings import settings settings.log_level = log_level = logging.DEBUG
The following methods are searched in order for a setting:
4. immediate values 3. previously user-set value 2. environment variable 1. system setting 0. implicit default
An implicit default is (optionally) defined by the setting attribute itself.
A system setting value can be obtained from registries or other OS configuration for settings that support that method.
An environment variable value is obtained from os.environ
User-set values many be specified by assigning to the attribute:
settings.log_level = log_level = logging.DEBUG
Immediate values are (optionally) provided when the setting is retrieved:
settings.log_level(logging.DEBUG())
Immediate values are most often useful to provide from optional arguments to client functions. If the argument value is not None, it will be returned as-is. Otherwise, the setting searches other methods according to the precedence rules.
Immutable configuration snapshots can be created with the following methods:
settings.defaults returns the base defaultsvalues , ignoring any environment or system or user settings
settings.current returns the current computation of settings including prioritization of configuration sources, unless defaults_only is set to True (in which case the result is identical to settings.defaults)
settings.config can be called with specific values to override what settings.current would provide
# return current settings with log level overridden settings.config(log_level=logging.DEBUG)
log_level â a log level to use across all Azure client SDKs (AZURE_LOG_LEVEL)
tracing_enabled â Whether tracing should be enabled across Azure SDKs (AZURE_TRACING_ENABLED)
tracing_implementation â The tracing implementation to use (AZURE_SDK_TRACING_IMPLEMENTATION)
>>> import logging >>> from azure.core.settings import settings >>> settings.log_level = logging.DEBUG >>> settings.log_level() 10
>>> settings.log_level(logging.WARN) 30
Return the currently computed settings, with values overridden by parameter values.
namedtuple
The current values for all settings, with values overridden by parameter values
Examples:
# return current settings with log level overridden settings.config(log_level=logging.DEBUG)
Return a value for a global setting according to configuration precedence.
The following methods are searched in order for the setting:
4. immediate values 3. previously user-set value 2. environment variable 1. system setting 0. implicit default
If a value cannot be determined, a RuntimeError is raised.
The env_var
argument specifies the name of an environment to check for setting values, e.g. "AZURE_LOG_LEVEL"
. If a convert
function is provided, the result will be converted before being used.
The optional system_hook
can be used to specify a function that will attempt to look up a value for the setting from system-wide configurations. If a convert
function is provided, the hook result will be converted before being used.
The optional default
argument specified an implicit default value for the setting that is returned if no other methods provide a value. If a convert
function is provided, default
will be converted before being used.
A convert
argument may be provided to convert values before they are returned. For instance to concert log levels in environment variables to logging
module values. If a convert
function is provided, it must support str as valid input type.
name (str) â the name of the setting
env_var (str) â the name of an environment variable to check for the setting
system_hook (callable) â a function that will attempt to look up a value for the setting
default (any) â an implicit default value for the setting
convert (callable) â a function to convert values before they are returned
Return the current values for all settings.
namedtuple
The current values for all settings
Return implicit default values for all settings, ignoring environment and system.
namedtuple
The implicit default values for all settings
Whether to ignore environment and system settings and return only base default values.
Whether to ignore environment and system settings and return only base default values.
Return a value for a global setting according to configuration precedence.
The following methods are searched in order for the setting:
4. immediate values 3. previously user-set value 2. environment variable 1. system setting 0. implicit default
If a value cannot be determined, a RuntimeError is raised.
The env_var
argument specifies the name of an environment to check for setting values, e.g. "AZURE_LOG_LEVEL"
. If a convert
function is provided, the result will be converted before being used.
The optional system_hook
can be used to specify a function that will attempt to look up a value for the setting from system-wide configurations. If a convert
function is provided, the hook result will be converted before being used.
The optional default
argument specified an implicit default value for the setting that is returned if no other methods provide a value. If a convert
function is provided, default
will be converted before being used.
A convert
argument may be provided to convert values before they are returned. For instance to concert log levels in environment variables to logging
module values. If a convert
function is provided, it must support str as valid input type.
name (str) â the name of the setting
env_var (str) â the name of an environment variable to check for the setting
system_hook (callable) â a function that will attempt to look up a value for the setting
default (any) â an implicit default value for the setting
convert (callable) â a function to convert values before they are returned
Return a value for a global setting according to configuration precedence.
The following methods are searched in order for the setting:
4. immediate values 3. previously user-set value 2. environment variable 1. system setting 0. implicit default
If a value cannot be determined, a RuntimeError is raised.
The env_var
argument specifies the name of an environment to check for setting values, e.g. "AZURE_LOG_LEVEL"
. If a convert
function is provided, the result will be converted before being used.
The optional system_hook
can be used to specify a function that will attempt to look up a value for the setting from system-wide configurations. If a convert
function is provided, the hook result will be converted before being used.
The optional default
argument specified an implicit default value for the setting that is returned if no other methods provide a value. If a convert
function is provided, default
will be converted before being used.
A convert
argument may be provided to convert values before they are returned. For instance to concert log levels in environment variables to logging
module values. If a convert
function is provided, it must support str as valid input type.
name (str) â the name of the setting
env_var (str) â the name of an environment variable to check for the setting
system_hook (callable) â a function that will attempt to look up a value for the setting
default (any) â an implicit default value for the setting
convert (callable) â a function to convert values before they are returned
Return a value for a global setting according to configuration precedence.
The following methods are searched in order for the setting:
4. immediate values 3. previously user-set value 2. environment variable 1. system setting 0. implicit default
If a value cannot be determined, a RuntimeError is raised.
The env_var
argument specifies the name of an environment to check for setting values, e.g. "AZURE_LOG_LEVEL"
. If a convert
function is provided, the result will be converted before being used.
The optional system_hook
can be used to specify a function that will attempt to look up a value for the setting from system-wide configurations. If a convert
function is provided, the hook result will be converted before being used.
The optional default
argument specified an implicit default value for the setting that is returned if no other methods provide a value. If a convert
function is provided, default
will be converted before being used.
A convert
argument may be provided to convert values before they are returned. For instance to concert log levels in environment variables to logging
module values. If a convert
function is provided, it must support str as valid input type.
name (str) â the name of the setting
env_var (str) â the name of an environment variable to check for the setting
system_hook (callable) â a function that will attempt to look up a value for the setting
default (any) â an implicit default value for the setting
convert (callable) â a function to convert values before they are returned
The settings unique instance.
A JSON encoder thatâs capable of serializing datetime objects and bytes.
Constructor for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float, bool or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.
If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be an (item_separator, key_separator) tuple. The default is (â, â, â: â) if indent is None
and (â,â, â: â) otherwise. To get the most compact JSON representation, you should specify (â,â, â:â) to eliminate whitespace.
If specified, default is a function that gets called for objects that canât otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError
.
Override the default method to handle datetime and bytes serialization. :param o: The object to serialize. :type o: any :return: A JSON-serializable representation of the object. :rtype: any
Return a JSON string representation of a Python data structure.
>>> from json.encoder import JSONEncoder >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}'
Encode the given object and yield each string representation as available.
For example:
for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk)
Convert an object to a dictionary of its attributes.
Made solely for backcompatibility with the legacy .as_dict() on msrest models.
Get a list of attribute names for a generated SDK model.
obj (any) â The object to get attributes from.
A list of attribute names.
List[str]
Check if the object is a generated SDK model.
obj (any) â The object to check.
True if the object is a generated SDK model, False otherwise.
A falsy sentinel object which is supposed to be used to specify attributes with no data. This gets serialized to null on the wire.
Abstract base class for Async HTTP responses.
Use this abstract base class to create your own transport responses.
Responses implementing this ABC are returned from your async clientâs send_request method if you pass in an HttpRequest
>>> from azure.core.rest import HttpRequest >>> request = HttpRequest('GET', 'http://www.example.com') <HttpRequest [GET], url: 'http://www.example.com'> >>> response = await client.send_request(request) <AsyncHttpResponse: 200 OK>
Asynchronously iterates over the responseâs bytes. Will decompress in the process.
An async iterator of bytes from the response
AsyncIterator[bytes]
Asynchronously iterates over the responseâs bytes. Will not decompress in the process.
An async iterator of bytes from the response
AsyncIterator[bytes]
Returns the whole body as a json object.
The JSON deserialized response body
any
json.decoder.JSONDecodeError â if the body is not valid JSON.
Raises an HttpResponseError if the response has an error status code.
If response is good, does nothing.
HttpResponseError â if the object has an error status code.
Read the responseâs bytes into memory.
The responseâs bytes
Returns the response body as a string.
Return the responseâs content in bytes.
The responseâs content in bytes.
The content type of the response.
The content type of the response.
Returns the response encoding.
The response encoding. We either return the encoding set by the user, or try extracting the encoding from the responseâs content type. If all fails, we return None.
optional[str]
The response headers. Must be case-insensitive.
Whether the network connection has been closed yet.
Whether the network connection has been closed yet.
Whether the stream has been consumed.
Whether the stream has been consumed.
The reason phrase for this response.
The reason phrase for this response.
The request that resulted in this response.
The request that resulted in this response.
The status code of this response.
The status code of this response.
The URL that resulted in this response.
The URL that resulted in this response.
An HTTP request.
It should be passed to your clientâs send_request method.
>>> 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>
params (mapping) â Query parameters to be mapped into your URL. Your input should be a mapping of query name to query value(s).
headers (mapping) â HTTP headers you want in your request. Your input should be a mapping of header name to header value.
json (any) â A JSON serializable object. We handle JSON-serialization for your object, so use this for more complicated data structures than data.
content (str or bytes or iterable[bytes] or asynciterable[bytes]) â Content you want in your request body. Think of it as the kwarg you should input if your data doesnât fit into json, data, or files. Accepts a bytes type, or a generator that yields bytes.
data (dict) â Form data you want in your request body. Use for form-encoded data, i.e. HTML forms.
files (mapping) â Files you want to in your request body. Use for uploading files with multipart encoding. Your input should be a mapping of file name to file content. Use the data kwarg in addition if you want to include non-file data files as part of your request.
Getâs the requestâs content
The requestâs content
any
Abstract base class for HTTP responses.
Use this abstract base class to create your own transport responses.
Responses implementing this ABC are returned from your clientâs send_request method if you pass in an HttpRequest
>>> 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>
Iterates over the responseâs bytes. Will decompress in the process.
An iterator of bytes from the response
Iterator[str]
Iterates over the responseâs bytes. Will not decompress in the process.
An iterator of bytes from the response
Iterator[str]
Returns the whole body as a json object.
The JSON deserialized response body
any
json.decoder.JSONDecodeError â if the body is not valid JSON.
Raises an HttpResponseError if the response has an error status code.
If response is good, does nothing.
HttpResponseError â if the object has an error status code.
Read the responseâs bytes.
The read in bytes
Returns the response body as a string.
Return the responseâs content in bytes.
The responseâs content in bytes.
The content type of the response.
The content type of the response.
Returns the response encoding.
The response encoding. We either return the encoding set by the user, or try extracting the encoding from the responseâs content type. If all fails, we return None.
optional[str]
The response headers. Must be case-insensitive.
Whether the network connection has been closed yet.
Whether the network connection has been closed yet.
Whether the stream has been consumed.
Whether the stream has been consumed.
The reason phrase for this response.
The reason phrase for this response.
The request that resulted in this response.
The request that resulted in this response.
The status code of this response.
The status code of this response.
The URL that resulted in this response.
The URL that resulted in this response.
This utils module provides functionality that is intended to be used by developers building on top of azure-core.
NOTE: This implementation is heavily inspired from the case insensitive dictionary from the requests library. Thank you !! Case insensitive dictionary implementation. The keys are expected to be strings and will be stored in lower case. case_insensitive_dict = CaseInsensitiveDict() case_insensitive_dict[âKeyâ] = âsome_valueâ case_insensitive_dict[âkeyâ] == âsome_valueâ #True
data (Mapping[str, Any] or Iterable[Tuple[str, Any]]) â Initial data to store in the dictionary.
If key is not found, d is returned if given, otherwise KeyError is raised.
as a 2-tuple; but raise KeyError if D is empty.
If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
Return a case-insensitive mutable mapping from an inputted mapping structure.
Parses the connection string into a dict of its component parts, with the option of preserving case of keys, and validates that each key in the connection string has a provided value. If case of keys is not preserved (ie. case_sensitive_keys=False), then a dict with LOWERCASE KEYS will be returned.
Mapping
Dict of connection string key/value pairs.
ValueError â if each key in conn_str does not have a corresponding value and for other bad formatting of connection strings - including duplicate args, bad syntax, etc.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4