Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def login(client_id, tenant, authority_url, resource, settings_file, force):
"""
Login command.
"""
# Get settings
settings = SettingsBuilder.get_authentication_settings(
settings_file=settings_file,
client_id=client_id,
tenant=tenant,
authority_url=authority_url,
resource=resource)
get_authentication(
settings=settings,
force_authenticate=force)
display('Login successful.')
icon=None,
connector_id=None,
powerapps_url=powerapps_url,
powerapps_version=powerapps_version)
powerapps_rp, _ = load_powerapps_and_flow_rp(
settings=settings,
command_context=_DOWNLOAD)
directory = paconn.operations.download.download(
powerapps_rp=powerapps_rp,
settings=settings,
destination=destination,
overwrite=overwrite)
display('The connector is downloaded to {}.'.format(directory))
connector_id=connector_id,
powerapps_url=powerapps_url,
powerapps_version=powerapps_version)
powerapps_rp, _ = load_powerapps_and_flow_rp(
settings=settings,
command_context=_UPDATE)
connector_id = upsert(
powerapps_rp=powerapps_rp,
settings=settings,
client_secret=client_secret,
is_update=True,
overwrite_settings=False)
display('{} updated successfully.'.format(connector_id))
connector_id=None,
powerapps_url=powerapps_url,
powerapps_version=powerapps_version)
powerapps_rp, _ = load_powerapps_and_flow_rp(
settings=settings,
command_context=_VALIDATE)
result = paconn.operations.validate.validate(
powerapps_rp=powerapps_rp,
settings=settings)
if result:
display(result)
else:
display('{} validated successfully.'.format(settings.api_definition))
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
api_definition=api_definition,
icon=None,
connector_id=None,
powerapps_url=powerapps_url,
powerapps_version=powerapps_version)
powerapps_rp, _ = load_powerapps_and_flow_rp(
settings=settings,
command_context=_VALIDATE)
result = paconn.operations.validate.validate(
powerapps_rp=powerapps_rp,
settings=settings)
if result:
display(result)
else:
display('{} validated successfully.'.format(settings.api_definition))
connector_id=None,
powerapps_url=powerapps_url,
powerapps_version=powerapps_version)
powerapps_rp, _ = load_powerapps_and_flow_rp(
settings=settings,
command_context=_CREATE)
connector_id = upsert(
powerapps_rp=powerapps_rp,
settings=settings,
client_secret=client_secret,
is_update=False,
overwrite_settings=overwrite_settings)
display('{} created successfully.'.format(connector_id))