How to use the paconn.common.util.format_json function in paconn

To help you get started, we’ve selected a few paconn 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 microsoft / PowerPlatformConnectors / tools / paconn-cli / paconn / apimanager / apimanager.py View on Github external
token=token)
            }
        if headers:
            all_headers.update(headers)

        response = requests.request(
            verb,
            endpoint,
            headers=all_headers,
            json=payload)
        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError as exception:
            exception_str = str(exception)
            response_content = json.loads(response.content)
            response_content = format_json(response_content)
            if payload:
                LOGGER.debug('PAYLOAD')
                LOGGER.debug(payload)
            LOGGER.debug('RESPONSE')
            LOGGER.debug(response_content)
            display(response_content)
            raise CLIError(exception_str)

        return response
github microsoft / PowerPlatformConnectors / tools / paconn-cli / paconn / settings / settingsserializer.py View on Github external
def to_json_string(settings):
        """
        Serializes a settings object into string
        """
        settings_dict = SettingsSerializer.serialize(settings)
        json_str = format_json(settings_dict)
        return json_str
github microsoft / PowerPlatformConnectors / tools / paconn-cli / paconn / operations / download.py View on Github external
]

    # Remove the keys that aren't present in the property JSON
    properties_present = list(
        filter(lambda prop: prop in api_properties, property_keys_whitelist)
    )

    # Only output the white listed properties that are present in the property JSON
    api_properties_selected = {_PROPERTIES: {}}
    api_properties_selected[_PROPERTIES] = {
        prop: api_properties[prop]
        for prop in properties_present
    }

    # Write the api properties
    api_prop = format_json(api_properties_selected)
    open(
        file=settings.api_properties,
        mode='w'
        ).write(api_prop)

    # Write the open api definition,
    # either from swagger URL when available or from swagger property.
    if _API_DEFINITIONS in api_properties and _ORIGINAL_SWAGGER_URL in api_properties[_API_DEFINITIONS]:
        original_swagger_url = api_properties[_API_DEFINITIONS][_ORIGINAL_SWAGGER_URL]
        response = requests.get(original_swagger_url, allow_redirects=True)
        response_string = response.content.decode('utf-8-sig')
        swagger = format_json(json.loads(response_string))
        open(
            file=settings.api_definition,
            mode='w'
            ).write(swagger)
github microsoft / PowerPlatformConnectors / tools / paconn-cli / paconn / operations / download.py View on Github external
}

    # Write the api properties
    api_prop = format_json(api_properties_selected)
    open(
        file=settings.api_properties,
        mode='w'
        ).write(api_prop)

    # Write the open api definition,
    # either from swagger URL when available or from swagger property.
    if _API_DEFINITIONS in api_properties and _ORIGINAL_SWAGGER_URL in api_properties[_API_DEFINITIONS]:
        original_swagger_url = api_properties[_API_DEFINITIONS][_ORIGINAL_SWAGGER_URL]
        response = requests.get(original_swagger_url, allow_redirects=True)
        response_string = response.content.decode('utf-8-sig')
        swagger = format_json(json.loads(response_string))
        open(
            file=settings.api_definition,
            mode='w'
            ).write(swagger)

    # Write the icon
    if _ICON_URI in api_properties:
        icon_url = api_properties[_ICON_URI]
        response = requests.get(icon_url, allow_redirects=True)
        open(
            file=settings.icon,
            mode='wb'
            ).write(response.content)

    return directory