http2py.cli_maker

http2py.cli_maker.dispatch_cli(openapi_spec: dict = '', url: str = '', filename: str = '', parse_yaml: bool = False, config_filename: str = '/home/runner/.http2py/credentials.json')[source]

Makes a CLI parser with mk_cli and then dispatches it (see documentation of mk_cli)

http2py.cli_maker.mk_argparse_friendly(func)[source]

Wraps a function to expose a signature that is compatible with argparse by stripping leading underscores from all keyword arguments, but does not mutate the signature of the original function

http2py.cli_maker.mk_cli(openapi_spec: dict = '', url: str = '', filename: str = '', parse_yaml: bool = False, config_filename: str = '/home/runner/.http2py/credentials.json')[source]

Creates a CLI parser that exposes all of the methods of an HTTP client defined by an OpenAPI spec. Accepts either an OpenAPI spec dict, a url, or path to a local file.

Parameters
  • openapi_spec – An OpenAPI service specification

  • url – A URL for an OpenAPI spec that can be accessed with an HTTP GET request

  • filename – The path to a local file that contains an OpenAPI spec

  • parse_yaml – A flag to indicate that the provided OpenAPI spec is in YAML format rather than JSON (default: False)

  • config_filename – The path to a local config file that contains authentication details for the HTTP service in JSON format (default: ~/.http2cli/credentials.json

http2py.cli_maker.mk_sig_argparse_friendly(sig)[source]

Modifies a signature to change all leading underscores in param names to trailing underscores, to ensure compatibility with argparse

http2py.cli_maker.register_cli_method(openapi_spec: dict, client_method: Callable, expected_auth_kwargs: Iterable[str] = None, config_filename: str = '/home/runner/.http2py/credentials.json', profile: str = '')[source]

Creates a CLI-friendly function to instantiate an HttpClient with appropriate authentication arguments and call a particular method of the client instance

Parameters
  • openapi_spec – The OpenAPI spec used to make the client

  • client_method – The instance method to wrap

  • expected_auth_kwargs – A list of authentication kwargs that the CLI should ask for (defaults to empty list)

  • config_filename – The path to a JSON file to read for authentication kwargs (defaults to ~/.http2py/credentials.json)

  • profile – The named profile to find in the config file