arjuna.tpi.httpauto.http module¶
- class arjuna.tpi.httpauto.http.Http¶
Bases:
object
The Facade class for HTTP Automation.
- class auth¶
Bases:
object
HTTP Authentication Builder
- classmethod basic(*, user, pwd)¶
Create an HTTP Basic Authentication object.
- classmethod digest(*, user, pwd)¶
Create an HTTP Basic Authentication object.
- class content¶
Bases:
object
- classmethod blank(content='')¶
Send empty content. Content-Type is sent as “text/html”
- classmethod bytes(content='')¶
Send bytes string. Content-Type is sent as “text/html”
- classmethod custom(content, *, type)¶
Send content with a custom content type.
- classmethod file(field_name, file_name, *, content_type='text/plain', headers=None)¶
Upload a file and send as multipart data. Content-Type is sent as the content type got from multipart encoding.
- classmethod get_content_type(handler_method)¶
- classmethod html(content=<arjuna.tpi.helper.arjtype.NotSet object>)¶
Send HTML content. Content-Type is sent as “text/html”
- classmethod json(content=<arjuna.tpi.helper.arjtype.NotSet object>)¶
Send a dictionary of key-values as JSON. Content-Type is sent as “application/json”
- classmethod multipart(*fields)¶
Send the provided HTTP fields as multipart data. Content-Type is sent as the content type got from multipart encoding.
- classmethod text(content=<arjuna.tpi.helper.arjtype.NotSet object>)¶
Send HTML content. Content-Type is sent as “text/html”
- classmethod urlencoded(content=<arjuna.tpi.helper.arjtype.NotSet object>)¶
Send a dictionary of key-values in URL encoded format. Content-Type is sent as “application/x-www-form-urlencoded”
- classmethod utf8(content='')¶
Send UTF-8 string. Content-Type is sent as “text/html”
- classmethod xml(content='')¶
Send an XML string as XML. Content-Type is sent as “application/xml
- classmethod field(name, value, is_file=False, content_type='text/plain', headers=None)¶
- classmethod oauth_auth_code_grant_service(*, name='anon', url, client_id, scope, redirect_uri=None, auth_url, auth_handler=None, token_url, **auth_args)¶
Create OAuthAuthCodeGrantService object.
Creates token using OAuth’s Auth Code Grant Type. Uses MobileApplicationClient from requests_oauthlib.
- Keyword Arguments
url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.
client_id – Client ID
scope – Scope
redirect_uri – Redirect URI
auth_url – Authorization URL
auth_handler – A callback function to handle custom authroization logic. It will be called by providing session object, authorization URL and auth_args.
token_url – Token URL
**auth_args – Arbitray key-value pairs to be passed as arguments to the auth_handler callback.
- Note:s
Some sample auth_handler signatures:
auth_handler_1(oauth_session, auth_url, **kwargs) auth_handler_2(oauth_session, auth_url, some_arg=None, another_arg="some_def_value")
- classmethod oauth_client_grant_service(*, name='anon', url, client_id, client_secret, token_url)¶
Create OAuthClientGrantService object.
Creates token using OAuth’s Resource Owner Client Credentials Grant Type. Uses BackendApplicationClient from requests_oauthlib.
- Keyword Arguments
url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.
client_id – Client ID
client_secret – Client Secret
token_url – Token URL
- classmethod oauth_implicit_grant_service(*, name='anon', url, client_id, scope, redirect_uri=None, auth_url, auth_handler=None, **auth_args)¶
Create OAuthImplicitGrantService object.
Creates token using OAuth’s Implicit Code Grant Type. Uses MobileApplicationClient from requests_oauthlib.
- Keyword Arguments
url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.
client_id – Client ID
scope – Scope
redirect_uri – Redirect URI
auth_url – Authorization URL
auth_handler – A callback function to handle custom authroization logic. It will be called by providing session object, authorization URL and auth_args.
**auth_args – Arbitray key-value pairs to be passed as arguments to the auth_handler callback.
- Note:s
Some sample auth_handler signatures:
auth_handler_1(oauth_session, auth_url, **kwargs) auth_handler_2(oauth_session, auth_url, some_arg=None, another_arg="some_def_value")
- classmethod proxy(host='localhost', port=8080)¶
Create a proxy dict.
- Parameters
host – Proxy host name/IP. Default is localhost
port – Proxy network port. Default is 8080
- classmethod service(*, name='anon', url=None, oauth_token=None, request_content_handler=None, headers=None, max_redirects=None, auth=None, proxy=None)¶
Create an HTTP Service representing SEAMful automation in Arjuna.
- Keyword Arguments
name – Name of service. Should have a corresponding named directory in Project root/httpauto/service directory. If not provided then the name is set to anon and root directory is set to Project root/httpauto.
url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.
oauth_token – OAuth 2.0 Bearer token for this service.
request_content_handler – Default content type handler for requests sent in this service. Overridable in individual sender methods. Default is Http.content.urlencoded.
headers – HTTP headers to be added to request headers made by this service.
max_redirects – Maximum number of redirects allowed for a request. Default is 30.
auth – HTTP Authentication object: Basic/Digest.
proxy – Proxies dict to be associated with this service.