the name of the plugin eg my auth optional short description it will be shown in the help under authtype this be set automatically once the plugin has been loaded base auth plugin class see httpientlm for an example auth plugin https github comhttpiehttpientlm see also testauthplugins py the value that should be passed to authtype to use this auth plugin eg myauth set to false to make it possible to invoke this auth plugin without requiring the user to specify credentials through auth a by default the a argument is parsed for username password set this to false to disable the parsing and error handling set to true to make it possible for this auth plugin to acquire credentials from the users netrc files it is used as a fallback when the credentials are not provided explicitly through auth a enabling this will allow skipping auth a even when authrequire is set true provided that netrc provides credential for a given host if both authparse and promptpassword are set to true and the value of a lacks the password part then the user will be prompted to type the password in will be set to the raw value of a if provided before getauth gets called if the credentials came from a netrc file then this is none if authparse is set to true then username and password contain the parsed credentials use self rawauth to access the raw value passed through auth a return a requests auth authbase subclass instance requests transport adapter docs https requests readthedocs ioenlatestuseradvancedtransportadapters see httpieunixsocket for an example transport plugin https github comhttpiehttpieunixsocket the url prefix the adapter should be mount to return a requests adapters baseadapter subclass instance to be mounted to self prefix possibly converts binary response data for prettified terminal display see httpiemsgpack for an example converter plugin https github comraskyhttpiemsgpack convert a binary body to a textual representation for the terminal and return a tuple containing the new contenttype and content e g applicationjson possibly formats response body headers for prettified terminal display param env an class environment instance param kwargs additional keyword argument that some formatters might require return processed headers param headers the headers as text return processed content param mime e g applicationatomxml param content the body content as text return processed metadata param metadata the metadata as text the name of the plugin eg my auth optional short description it will be shown in the help under auth type this be set automatically once the plugin has been loaded base auth plugin class see httpie ntlm for an example auth plugin https github com httpie httpie ntlm see also test_auth_plugins py the value that should be passed to auth type to use this auth plugin eg my auth set to false to make it possible to invoke this auth plugin without requiring the user to specify credentials through auth a by default the a argument is parsed for username password set this to false to disable the parsing and error handling set to true to make it possible for this auth plugin to acquire credentials from the user s netrc file s it is used as a fallback when the credentials are not provided explicitly through auth a enabling this will allow skipping auth a even when auth_require is set true provided that netrc provides credential for a given host if both auth_parse and prompt_password are set to true and the value of a lacks the password part then the user will be prompted to type the password in will be set to the raw value of a if provided before get_auth gets called if the credentials came from a netrc file then this is none if auth_parse is set to true then username and password contain the parsed credentials use self raw_auth to access the raw value passed through auth a return a requests auth authbase subclass instance requests transport adapter docs https requests readthedocs io en latest user advanced transport adapters see httpie unixsocket for an example transport plugin https github com httpie httpie unixsocket the url prefix the adapter should be mount to return a requests adapters baseadapter subclass instance to be mounted to self prefix possibly converts binary response data for prettified terminal display see httpie msgpack for an example converter plugin https github com rasky httpie msgpack convert a binary body to a textual representation for the terminal and return a tuple containing the new content type and content e g application json possibly formats response body headers for prettified terminal display param env an class environment instance param kwargs additional keyword argument that some formatters might require return processed headers param headers the headers as text return processed content param mime e g application atom xml param content the body content as text return processed metadata param metadata the metadata as text
from typing import Tuple


class BasePlugin:
    
    name = None

    
    
    description = None

    
    package_name = None


class AuthPlugin(BasePlugin):
    
    
    
    auth_type = None

    
    
    
    auth_require = True

    
    
    auth_parse = True

    
    
    
    
    
    
    netrc_parse = False

    
    
    
    prompt_password = True

    
    
    
    raw_auth = None

    def get_auth(self, username: str = None, password: str = None):
        
        raise NotImplementedError()


class TransportPlugin(BasePlugin):
    

    
    prefix = None

    def get_adapter(self):
        
        raise NotImplementedError()


class ConverterPlugin(BasePlugin):
    

    def __init__(self, mime: str):
        self.mime = mime

    def convert(self, body: bytes) -> Tuple[str, str]:
        
        raise NotImplementedError

    @classmethod
    def supports(cls, mime: str) -> bool:
        raise NotImplementedError


class FormatterPlugin(BasePlugin):
    
    group_name = 'format'

    def __init__(self, **kwargs):
        
        self.enabled = True
        self.kwargs = kwargs
        self.format_options = kwargs['format_options']

    def format_headers(self, headers: str) -> str:
        
        return headers

    def format_body(self, content: str, mime: str) -> str:
        
        return content

    def format_metadata(self, metadata: str) -> str:
        
        return metadata