def request_ovh_client(consumer_key=None):
try:
import requests
import requests.exceptions
except ImportError:
print('The requests library is needed to perform this command:')
print(' pip install requests')
print(' apt-get install python3-requests')
exit(1)
client = Client(
endpoint='ovh-eu',
application_key='yVPsINnSdHOLTGHf',
application_secret='5mVDkHaJw6rp5GYiYBUlgDv1vruRejkl',
consumer_key=consumer_key
)
if not consumer_key:
response = client.request_consumerkey(
access_rules=[
{'method': 'GET', 'path': '/paas/monitoring'},
{'method': 'GET', 'path': '/paas/monitoring/*'},
{'method': 'POST', 'path': '/paas/monitoring/*'},
{'method': 'PUT', 'path': '/paas/monitoring/*'},
{'method': 'DELETE', 'path': '/paas/monitoring/*'}
]
)
response = response.json()
print('New consumer key:', response['consumerKey'])
print('Validate it at', response['validationUrl'])
input('When you are ready, press Enter')
try:
client.get('/paas/monitoring')
except requests.exceptions.HTTPError as e:
if not e.response.status_code == 403:
raise
return request_ovh_client()
return client
评论列表
文章目录