How to use the hubspot3.__main__.Hubspot3CLIWrapper function in hubspot3

To help you get started, we’ve selected a few hubspot3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jpetrucciani / hubspot3 / hubspot3 / __main__.py View on Github external
"""
    client_args, call_args, fire_args = split_args()

    if fire_args:
        # If there are arguments for an actual API method call, append the Fire
        # arguments to that second call. Otherwise, append them to the first
        # call as there won't be a second one.
        (call_args or client_args).extend(["--"] + fire_args)
    if call_args:
        # Use the non-printing Fire routine for the first call as only the
        # result of the second, actual API call should be printed.
        component_trace = fire_execute(Hubspot3CLIWrapper, client_args, {}, __package__)
        wrapper = component_trace.GetResult()
        fire(wrapper, call_args)
    else:
        fire(Hubspot3CLIWrapper, client_args, __package__)
github jpetrucciani / hubspot3 / hubspot3 / __main__.py View on Github external
Split the execution up into two Fire calls: one that creates the main
    Hubspot3CLIWrapper instance and one that works on this instance. That way,
    the argument separator is not required and sensible details like the API
    key are not printed out.
    """
    client_args, call_args, fire_args = split_args()

    if fire_args:
        # If there are arguments for an actual API method call, append the Fire
        # arguments to that second call. Otherwise, append them to the first
        # call as there won't be a second one.
        (call_args or client_args).extend(["--"] + fire_args)
    if call_args:
        # Use the non-printing Fire routine for the first call as only the
        # result of the second, actual API call should be printed.
        component_trace = fire_execute(Hubspot3CLIWrapper, client_args, {}, __package__)
        wrapper = component_trace.GetResult()
        fire(wrapper, call_args)
    else:
        fire(Hubspot3CLIWrapper, client_args, __package__)
github jpetrucciani / hubspot3 / hubspot3 / __main__.py View on Github external
# Find properties by searching the class first - that way, a call
            # to getattr doesn't run the properties code on the object.
            if (
                attr.startswith("_")
                or attr in self.IGNORED_PROPERTIES
                or not isinstance(getattr(hubspot3.__class__, attr), property)
            ):
                continue
            client = getattr(hubspot3, attr)
            if isinstance(client, BaseClient):
                clients[attr] = client
        return clients


class ClientCLIWrapper(object):
    __doc__ = Hubspot3CLIWrapper.__doc__

    # Mapping (client class to attribute names) to define methods that should
    # be ignored during method discovery.
    # Extend this mapping if more methods that aren't API methods are added to
    # a client class.
    IGNORED_METHODS = {LeadsClient: ("camelcase_search_options",)}
    STDIN_TOKEN = "__stdin__"  # Argument value to trigger stdin parsing.

    def __init__(self, client: BaseClient) -> None:
        self._client_name = client.__class__.__name__
        # Discover all API methods and set them as attributes on this wrapper
        # so Fire can discover them.
        self._methods = self._discover_methods(client)
        for attr, method in self._methods.items():
            setattr(self, attr, self._build_method_wrapper(method))