4.7.4.6. URLs

HTTP client.

class axonius_api_client.parsers.url_parser.UrlParser(url, default_scheme='https')[source]

Bases: object

Parse a URL and ensure it has the neccessary bits.

Parameters
  • url (str) –

  • default_scheme (str) –

__init__(url, default_scheme='https')[source]

Parse a URL and ensure it has the neccessary bits.

Parameters
  • url (str) – URL to parse

  • default_scheme (str) – scheme to use if url does not contain a scheme

Raises

HttpError – if parsed URL winds up without a hostname, port, or scheme.

INIT_URL: str

initial URL provided

INIT_SCHEME: str

default scheme provided

INIT_PARSED

first pass of parsing URL

Type

urllib.parse.ParseResult

parsed

second pass of parsing URL

Type

urllib.parse.ParseResult

__str__()[source]

Show object info.

Return type

str

__repr__()[source]

Show object info.

Return type

str

property hostname

Hostname part from UrlParser.parsed.

Return type

str

property port

Port part from UrlParser.parsed.

Return type

int

property scheme

Scheme part from UrlParser.parsed.

Return type

str

property url

Get scheme, hostname, and port from UrlParser.parsed.

Return type

str

property url_full

Get full URL from UrlParser.parsed.

Return type

str

property parsed_str

Get a str value of UrlParser.parsed.

Return type

str

make_netloc(host, port)[source]

Create netloc from host and port.

Parameters
  • hosthost – hostname to use in netloc

  • portport – port to use in netloc

  • host (str) –

  • port (typing.Union[str, int]) –

Return type

str

reparse(parsed, default_scheme='')[source]

Reparse a parsed URL into a parsed URL with values fixed.

Parameters
  • parsed (urllib.parse.ParseResult) – parsed URL to reparse

  • default_scheme (str) – default scheme to use if URL does not contain a scheme

Returns

urllib.parse.ParseResult

unparse_base(parsed_result)[source]

Unparse a parsed URL into just the scheme, hostname, and port parts.

Parameters

parsed (urllib.parse.ParseResult) – parsed URL to unparse

Return type

str

unparse_all(parsed_result)[source]

Unparse a parsed URL with all the parts.

Parameters

parsed (urllib.parse.ParseResult) – parsed URL to unparse

Return type

str