desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'service_instance: service client instance. cert_file: certificate file path or location in windows certificate store. protocol: http or https. request_session: session object created with requests library (or compatible). timeout: timeout for the http request, in seconds. user_agent: user agent string to set in http h...
def __init__(self, service_instance, cert_file=None, protocol='https', request_session=None, timeout=65, user_agent=''):
self.service_instance = service_instance self.cert_file = cert_file self.protocol = protocol self.proxy_host = None self.proxy_port = None self.proxy_user = None self.proxy_password = None self.request_session = request_session self.timeout = timeout self.user_agent = user_agent
'Sets the proxy server host and port for the HTTP CONNECT Tunnelling. host: Address of the proxy. Ex: \'192.168.0.100\' port: Port of the proxy. Ex: 6000 user: User for proxy authorization. password: Password for proxy authorization.'
def set_proxy(self, host, port, user, password):
self.proxy_host = host self.proxy_port = port self.proxy_user = user self.proxy_password = password
'Return the target uri for the request.'
def get_uri(self, request):
protocol = (request.protocol_override if request.protocol_override else self.protocol) protocol = protocol.lower() port = (HTTP_PORT if (protocol == 'http') else HTTPS_PORT) return (((((protocol + '://') + request.host) + ':') + str(port)) + request.path)
'Create connection for the request.'
def get_connection(self, request):
protocol = (request.protocol_override if request.protocol_override else self.protocol) protocol = protocol.lower() target_host = request.host target_port = (HTTP_PORT if (protocol == 'http') else HTTPS_PORT) if self.request_session: from .requestsclient import _RequestsConnection con...
'pulls the query string out of the URI and moves it into the query portion of the request object. If there are already query parameters on the request the parameters in the URI will appear after the existing parameters'
def _update_request_uri_query(self, request):
if ('?' in request.path): (request.path, _, query_string) = request.path.partition('?') if query_string: query_params = query_string.split('&') for query in query_params: if ('=' in query): (name, _, value) = query.partition('=') ...
'Sends request to cloud service server and return the response.'
def perform_request(self, request):
connection = self.get_connection(request) try: connection.putrequest(request.method, request.path) if (not self.request_session): if (self.proxy_host and self.proxy_user): connection.set_proxy_credentials(self.proxy_user, self.proxy_password) self.send_request...
'Parse the HTTPResponse\'s body and fill all the data into a class of return_type.'
@staticmethod def parse_response(response, return_type):
doc = minidom.parseString(response.body) return_obj = return_type() xml_name = (return_type._xml_name if hasattr(return_type, '_xml_name') else return_type.__name__) for node in _MinidomXmlToObject.get_child_nodes(doc, xml_name): _MinidomXmlToObject._fill_data_to_return_object(node, return_obj) ...
'Parse the HTTPResponse\'s body and fill all the data into a class of return_type.'
@staticmethod def parse_service_resources_response(response, return_type):
doc = minidom.parseString(response.body) return_obj = _list_of(return_type) for node in _MinidomXmlToObject.get_children_from_path(doc, 'ServiceResources', 'ServiceResource'): local_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(node, local_obj) return_obj.append...
'get properties from entry xml'
@staticmethod def get_entry_properties_from_node(entry, include_id, id_prefix_to_skip=None, use_title_as_id=False):
properties = {} etag = entry.getAttributeNS(METADATA_NS, 'etag') if etag: properties['etag'] = etag for updated in _MinidomXmlToObject.get_child_nodes(entry, 'updated'): properties['updated'] = updated.firstChild.nodeValue for name in _MinidomXmlToObject.get_children_from_path(entry,...
'descends through a hierarchy of nodes returning the list of children at the inner most level. Only returns children who share a common parent, not cousins.'
@staticmethod def get_children_from_path(node, *path):
cur = node for (index, child) in enumerate(path): if isinstance(child, _strtype): next = _MinidomXmlToObject.get_child_nodes(cur, child) else: next = _MinidomXmlToObject._get_child_nodesNS(cur, *child) if (index == (len(path) - 1)): return next ...
'parse the xml and fill all the data into a class of return_type'
@staticmethod def _parse_response_body_from_xml_node(node, return_type):
return_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(node, return_obj) return return_obj
'Converts an xml fragment into a list of scalar types. The parent xml element contains a flat list of xml elements which are converted into the specified scalar type and added to the list. Example: xmldoc= <Endpoints> <Endpoint>http://{storage-service-name}.blob.core.windows.net/</Endpoint> <Endpoint>http://{storage-s...
@staticmethod def _fill_scalar_list_of(xmldoc, element_type, parent_xml_element_name, xml_element_name):
xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, parent_xml_element_name) if xmlelements: xmlelements = _MinidomXmlToObject.get_child_nodes(xmlelements[0], xml_element_name) return [_MinidomXmlToObject._get_node_value(xmlelement, element_type) for xmlelement in xmlelements]
'Converts an xml fragment into a dictionary. The parent xml element contains a list of xml elements where each element has a child element for the key, and another for the value. Example: xmldoc= <ExtendedProperties> <ExtendedProperty> <Name>Ext1</Name> <Value>Val1</Value> </ExtendedProperty> <ExtendedProperty> <Name>E...
@staticmethod def _fill_dict_of(xmldoc, parent_xml_element_name, pair_xml_element_name, key_xml_element_name, value_xml_element_name):
return_obj = {} xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, parent_xml_element_name) if xmlelements: xmlelements = _MinidomXmlToObject.get_child_nodes(xmlelements[0], pair_xml_element_name) for pair in xmlelements: keys = _MinidomXmlToObject.get_child_nodes(pair, ke...
'Converts a child of the current dom element to the specified type.'
@staticmethod def _fill_instance_child(xmldoc, element_name, return_type):
xmlelements = _MinidomXmlToObject.get_child_nodes(xmldoc, _get_serialization_name(element_name)) if (not xmlelements): return None return_obj = return_type() _MinidomXmlToObject._fill_data_to_return_object(xmlelements[0], return_obj) return return_obj
'Recursively searches from the parent to the child, gathering all the applicable namespaces along the way'
@staticmethod def _find_namespaces_from_child(parent, child, namespaces):
for cur_child in parent.childNodes: if (cur_child is child): return True if _MinidomXmlToObject._find_namespaces_from_child(cur_child, child, namespaces): for key in cur_child.attributes.keys(): if (key.startswith('xmlns:') or (key == 'xmlns')): ...
'Wraps the specified xml in an xml root element with default azure namespaces'
@staticmethod def doc_from_xml(document_element_name, inner_xml):
xml = ''.join(['<', document_element_name, ' xmlns:i="http://www.w3.org/2001/XMLSchema-instance"', ' xmlns="http://schemas.microsoft.com/windowsazure">']) xml += inner_xml xml += ''.join(['</', document_element_name, '>']) return xml
'Wraps the specified xml in an xml root element with default azure namespaces'
@staticmethod def doc_from_xml(document_element_name, inner_xml, xmlns='http://schemas.microsoft.com/windowsazure'):
xml = ''.join(['<', document_element_name, ' xmlns="{0}">'.format(xmlns)]) xml += inner_xml xml += ''.join(['</', document_element_name, '>']) return xml
'Converts a service bus namespace description to xml The xml format: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <NamespaceDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Region>West US</Re...
@staticmethod def namespace_to_xml(region):
body = '<NamespaceDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">' body += ''.join(['<Region>', region, '</Region>']) body += '</NamespaceDescription>' return _create_entry(body)
'Converts xml response to service bus namespace The xml format for namespace: <entry> <id>uuid:00000000-0000-0000-0000-000000000000;id=0000000</id> <title type="text">myunittests</title> <updated>2012-08-22T16:48:10Z</updated> <content type="application/xml"> <NamespaceDescription xmlns="http://schemas.microsoft.com/ne...
@staticmethod def xml_to_namespace(xmlstr):
xmldoc = minidom.parseString(xmlstr) namespace = ServiceBusNamespace() mappings = (('Name', 'name', None), ('Region', 'region', None), ('DefaultKey', 'default_key', None), ('Status', 'status', None), ('CreatedAt', 'created_at', None), ('AcsManagementEndpoint', 'acs_management_endpoint', None), ('ServiceBusE...
'Converts xml response to service bus region The xml format for region: <entry> <id>uuid:157c311f-081f-4b4a-a0ba-a8f990ffd2a3;id=1756759</id> <title type="text"></title> <updated>2013-04-10T18:25:29Z</updated> <content type="application/xml"> <RegionCodeDescription xmlns="http://schemas.microsoft.com/netservices/2010/1...
@staticmethod def xml_to_region(xmlstr):
xmldoc = minidom.parseString(xmlstr) region = ServiceBusRegion() for desc in _MinidomXmlToObject.get_children_from_path(xmldoc, 'entry', 'content', 'RegionCodeDescription'): node_value = _MinidomXmlToObject.get_first_child_node_value(desc, 'Code') if (node_value is not None): reg...
'Converts xml response to service bus namespace availability The xml format: <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <id>uuid:9fc7c652-1856-47ab-8d74-cd31502ea8e6;id=3683292</id> <title type="text"></title> <updated>2013-04-16T03:03:37Z</updated> <content type="application/xml...
@staticmethod def xml_to_namespace_availability(xmlstr):
xmldoc = minidom.parseString(xmlstr) availability = AvailabilityResponse() for desc in _MinidomXmlToObject.get_children_from_path(xmldoc, 'entry', 'content', 'NamespaceAvailability'): node_value = _MinidomXmlToObject.get_first_child_node_value(desc, 'Result') if (node_value is not None): ...
'Convert odata type http://www.odata.org/documentation/odata-version-2-0/overview#AbstractTypeSystem To be completed'
@staticmethod def odata_converter(data, str_type):
if (not str_type): return _str(data) if (str_type in ['Edm.Single', 'Edm.Double']): return float(data) elif ('Edm.Int' in str_type): return int(data) else: return _str(data)
'Converts xml response to service bus metrics objects The xml format for MetricProperties <entry> <id>https://sbgm.windows.net/Metrics(\'listeners.active\')</id> <title/> <updated>2014-10-09T11:56:50Z</updated> <author> <name/> </author> <content type="application/xml"> <m:properties> <d:Name>listeners.active</d:Name> ...
@staticmethod def xml_to_metrics(xmlstr, object_type):
xmldoc = minidom.parseString(xmlstr) return_obj = object_type() members = dict(vars(return_obj)) for xml_entry in _MinidomXmlToObject.get_children_from_path(xmldoc, 'entry'): for node in _MinidomXmlToObject.get_children_from_path(xml_entry, 'content', 'properties'): for name in membe...
'<CloudService xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure"> <Label>MyApp3</Label> <Description>My Cloud Service for app3</Description> <GeoRegion>South Central US</GeoRegion> </CloudService>'
@staticmethod def create_cloud_service_to_xml(label, description, geo_region):
body = '<CloudService xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure">' body += ''.join(['<Label>', label, '</Label>']) body += ''.join(['<Description>', description, '</Description>']) body += ''.join(['<GeoRegion>', geo_region, '</GeoRegion>'...
'<Resource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure"> <IntrinsicSettings> <Plan>Standard</Plan> <Quota> <MaxJobCount>10</MaxJobCount> <MaxRecurrence> <Frequency>Second</Frequency> <Interval>1</Interval> </MaxRecurrence> </Quota> </IntrinsicSettings> </Resource...
@staticmethod def create_job_collection_to_xml(plan):
if (plan not in ['Free', 'Standard']): raise ValueError("Plan: Invalid option must be 'Standard' or 'Free'") body = '<Resource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure"><IntrinsicSettings>' body += ''.join(['<plan...
'Initializes the website management service. subscription_id: Subscription to manage. cert_file: Path to .pem certificate file (httplib), or location of the certificate in your Personal certificate store (winhttp) in the CURRENT_USER\my\CertificateName format. If a request_session is specified, then this is unused. hos...
def __init__(self, subscription_id=None, cert_file=None, host=MANAGEMENT_HOST, request_session=None, timeout=DEFAULT_HTTP_TIMEOUT):
super(WebsiteManagementService, self).__init__(subscription_id, cert_file, host, request_session, timeout)
'List the webspaces defined on the account.'
def list_webspaces(self):
return self._perform_get(self._get_list_webspaces_path(), WebSpaces)
'Get details of a specific webspace. webspace_name: The name of the webspace.'
def get_webspace(self, webspace_name):
return self._perform_get(self._get_webspace_details_path(webspace_name), WebSpace)
'List the web sites defined on this webspace. webspace_name: The name of the webspace.'
def list_sites(self, webspace_name):
return self._perform_get(self._get_sites_path(webspace_name), Sites)
'List the web sites defined on this webspace. webspace_name: The name of the webspace. website_name: The name of the website.'
def get_site(self, webspace_name, website_name):
return self._perform_get(self._get_sites_details_path(webspace_name, website_name), Site)
'Create a website. webspace_name: The name of the webspace. website_name: The name of the website. geo_region: The geographical region of the webspace that will be created. host_names: An array of fully qualified domain names for website. Only one hostname can be specified in the azurewebsites.net domain. The hostname ...
def create_site(self, webspace_name, website_name, geo_region, host_names, plan='VirtualDedicatedPlan', compute_mode='Shared', server_farm=None, site_mode=None):
xml = _XmlSerializer.create_website_to_xml(webspace_name, website_name, geo_region, plan, host_names, compute_mode, server_farm, site_mode) return self._perform_post(self._get_sites_path(webspace_name), xml, Site)
'Delete a website. webspace_name: The name of the webspace. website_name: The name of the website. delete_empty_server_farm: If the site being deleted is the last web site in a server farm, you can delete the server farm by setting this to True. delete_metrics: To also delete the metrics for the site that you are delet...
def delete_site(self, webspace_name, website_name, delete_empty_server_farm=False, delete_metrics=False):
path = self._get_sites_details_path(webspace_name, website_name) query = '' if delete_empty_server_farm: query += '&deleteEmptyServerFarm=true' if delete_metrics: query += '&deleteMetrics=true' if query: path = ((path + '?') + query.lstrip('&')) return self._perform_delet...
'Update a web site. webspace_name: The name of the webspace. website_name: The name of the website. state: The wanted state (\'Running\' or \'Stopped\' accepted)'
def update_site(self, webspace_name, website_name, state=None):
xml = _XmlSerializer.update_website_to_xml(state) return self._perform_put(self._get_sites_details_path(webspace_name, website_name), xml, async=True)
'Restart a web site. webspace_name: The name of the webspace. website_name: The name of the website.'
def restart_site(self, webspace_name, website_name):
return self._perform_post(self._get_restart_path(webspace_name, website_name), None, async=True)
'Get historical usage metrics. webspace_name: The name of the webspace. website_name: The name of the website. metrics: Optional. List of metrics name. Otherwise, all metrics returned. start_time: Optional. An ISO8601 date. Otherwise, current hour is used. end_time: Optional. An ISO8601 date. Otherwise, current time is...
def get_historical_usage_metrics(self, webspace_name, website_name, metrics=None, start_time=None, end_time=None, time_grain=None):
metrics = (('names=' + ','.join(metrics)) if metrics else '') start_time = (('StartTime=' + start_time) if start_time else '') end_time = (('EndTime=' + end_time) if end_time else '') time_grain = (('TimeGrain=' + time_grain) if time_grain else '') parameters = '&'.join((v for v in (metrics, start_t...
'Get metric definitions of metrics available of this web site. webspace_name: The name of the webspace. website_name: The name of the website.'
def get_metric_definitions(self, webspace_name, website_name):
return self._perform_get(self._get_metric_definitions_path(webspace_name, website_name), MetricDefinitions)
'Get a site\'s publish profile as a string webspace_name: The name of the webspace. website_name: The name of the website.'
def get_publish_profile_xml(self, webspace_name, website_name):
return self._perform_get(self._get_publishxml_path(webspace_name, website_name), None).body.decode('utf-8')
'Get a site\'s publish profile as an object webspace_name: The name of the webspace. website_name: The name of the website.'
def get_publish_profile(self, webspace_name, website_name):
return self._perform_get(self._get_publishxml_path(webspace_name, website_name), PublishData)
'Returns a new service which will process requests with the specified filter. Filtering operations can include logging, automatic retrying, etc... The filter is a lambda which receives the HTTPRequest and another lambda. The filter can perform any pre-processing on the request, pass it off to the next lambda, and th...
def with_filter(self, filter):
res = type(self)(self.subscription_id, self.cert_file, self.host, self.request_session, self._httpclient.timeout) old_filter = self._filter def new_filter(request): return filter(request, old_filter) res._filter = new_filter return res
'Sets the proxy server host and port for the HTTP CONNECT Tunnelling. host: Address of the proxy. Ex: \'192.168.0.100\' port: Port of the proxy. Ex: 6000 user: User for proxy authorization. password: Password for proxy authorization.'
def set_proxy(self, host, port, user=None, password=None):
self._httpclient.set_proxy(host, port, user, password)
'Performs a GET request and returns the response. path: Path to the resource. Ex: \'/<subscription-id>/services/hostedservices/<service-name>\' x_ms_version: If specified, this is used for the x-ms-version header. Otherwise, self.x_ms_version is used.'
def perform_get(self, path, x_ms_version=None):
request = HTTPRequest() request.method = 'GET' request.host = self.host request.path = path (request.path, request.query) = self._httpclient._update_request_uri_query(request) request.headers = self._update_management_header(request, x_ms_version) response = self._perform_request(request) ...
'Performs a PUT request and returns the response. path: Path to the resource. Ex: \'/<subscription-id>/services/hostedservices/<service-name>\' body: Body for the PUT request. x_ms_version: If specified, this is used for the x-ms-version header. Otherwise, self.x_ms_version is used.'
def perform_put(self, path, body, x_ms_version=None):
request = HTTPRequest() request.method = 'PUT' request.host = self.host request.path = path request.body = _get_request_body(body) (request.path, request.query) = self._httpclient._update_request_uri_query(request) request.headers = self._update_management_header(request, x_ms_version) r...
'Performs a POST request and returns the response. path: Path to the resource. Ex: \'/<subscription-id>/services/hostedservices/<service-name>\' body: Body for the POST request. x_ms_version: If specified, this is used for the x-ms-version header. Otherwise, self.x_ms_version is used.'
def perform_post(self, path, body, x_ms_version=None):
request = HTTPRequest() request.method = 'POST' request.host = self.host request.path = path request.body = _get_request_body(body) (request.path, request.query) = self._httpclient._update_request_uri_query(request) request.headers = self._update_management_header(request, x_ms_version) ...
'Performs a DELETE request and returns the response. path: Path to the resource. Ex: \'/<subscription-id>/services/hostedservices/<service-name>\' x_ms_version: If specified, this is used for the x-ms-version header. Otherwise, self.x_ms_version is used.'
def perform_delete(self, path, x_ms_version=None):
request = HTTPRequest() request.method = 'DELETE' request.host = self.host request.path = path (request.path, request.query) = self._httpclient._update_request_uri_query(request) request.headers = self._update_management_header(request, x_ms_version) response = self._perform_request(request)...
'Waits for an asynchronous operation to complete. This calls get_operation_status in a loop and returns when the expected status is reached. The result of get_operation_status is returned. By default, an exception is raised on timeout or error status. request_id: The request ID for the request you wish to track. wait_f...
def wait_for_operation_status(self, request_id, wait_for_status='Succeeded', timeout=30, sleep_interval=5, progress_callback=wait_for_operation_status_progress_default_callback, success_callback=wait_for_operation_status_success_default_callback, failure_callback=wait_for_operation_status_failure_default_callback):
loops = ((timeout // sleep_interval) + 1) start_time = time.time() for _ in range(int(loops)): result = self.get_operation_status(request_id) elapsed = (time.time() - start_time) if (result.status == wait_for_status): if (success_callback is not None): suc...
'Returns the status of the specified operation. After calling an asynchronous operation, you can call Get Operation Status to determine whether the operation has succeeded, failed, or is still in progress. request_id: The request ID for the request you wish to track.'
def get_operation_status(self, request_id):
_validate_not_none('request_id', request_id) return self._perform_get(((('/' + self.subscription_id) + '/operations/') + _str(request_id)), Operation)
'Add additional headers for management.'
def _update_management_header(self, request, x_ms_version):
if (request.method in ['PUT', 'POST', 'MERGE', 'DELETE']): request.headers.append(('Content-Length', str(len(request.body)))) request.headers.append(('x-ms-version', (x_ms_version or self.x_ms_version))) if (not (request.method in ['GET', 'HEAD'])): for (name, _) in request.headers: ...
'Initializes the service bus management service. subscription_id: Subscription to manage. cert_file: Path to .pem certificate file (httplib), or location of the certificate in your Personal certificate store (winhttp) in the CURRENT_USER\my\CertificateName format. If a request_session is specified, then this is unused....
def __init__(self, subscription_id=None, cert_file=None, host=MANAGEMENT_HOST, request_session=None, timeout=DEFAULT_HTTP_TIMEOUT):
super(ServiceBusManagementService, self).__init__(subscription_id, cert_file, host, request_session, timeout) self.x_ms_version = X_MS_VERSION
'Get list of available service bus regions.'
def get_regions(self):
response = self._perform_get(self._get_path('services/serviceBus/Regions/', None), None) return _MinidomXmlToObject.convert_response_to_feeds(response, _ServiceBusManagementXmlSerializer.xml_to_region)
'List the service bus namespaces defined on the account.'
def list_namespaces(self):
response = self._perform_get(self._get_path('services/serviceBus/Namespaces/', None), None) return _MinidomXmlToObject.convert_response_to_feeds(response, _ServiceBusManagementXmlSerializer.xml_to_namespace)
'Get details about a specific namespace. name: Name of the service bus namespace.'
def get_namespace(self, name):
response = self._perform_get(self._get_path('services/serviceBus/Namespaces', name), None) return _ServiceBusManagementXmlSerializer.xml_to_namespace(response.body)
'Create a new service bus namespace. name: Name of the service bus namespace to create. region: Region to create the namespace in.'
def create_namespace(self, name, region):
_validate_not_none('name', name) return self._perform_put(self._get_path('services/serviceBus/Namespaces', name), _ServiceBusManagementXmlSerializer.namespace_to_xml(region))
'Delete a service bus namespace. name: Name of the service bus namespace to delete.'
def delete_namespace(self, name):
_validate_not_none('name', name) return self._perform_delete(self._get_path('services/serviceBus/Namespaces', name), None)
'Checks to see if the specified service bus namespace is available, or if it has already been taken. name: Name of the service bus namespace to validate.'
def check_namespace_availability(self, name):
_validate_not_none('name', name) response = self._perform_get(((self._get_path('services/serviceBus/CheckNamespaceAvailability', None) + '/?namespace=') + _str(name)), None) return _ServiceBusManagementXmlSerializer.xml_to_namespace_availability(response.body)
'Enumerates the queues in the service namespace. name: Name of the service bus namespace.'
def list_queues(self, name):
_validate_not_none('name', name) response = self._perform_get(self._get_list_queues_path(name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_MinidomXmlToObject.convert_xml_to_azure_object, azure_type=QueueDescription))
'Retrieves the topics in the service namespace. name: Name of the service bus namespace.'
def list_topics(self, name):
response = self._perform_get(self._get_list_topics_path(name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_MinidomXmlToObject.convert_xml_to_azure_object, azure_type=TopicDescription))
'Retrieves the notification hubs in the service namespace. name: Name of the service bus namespace.'
def list_notification_hubs(self, name):
response = self._perform_get(self._get_list_notification_hubs_path(name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_MinidomXmlToObject.convert_xml_to_azure_object, azure_type=NotificationHubDescription))
'Retrieves the relays in the service namespace. name: Name of the service bus namespace.'
def list_relays(self, name):
response = self._perform_get(self._get_list_relays_path(name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_MinidomXmlToObject.convert_xml_to_azure_object, azure_type=RelayDescription))
'Retrieves the list of supported metrics for this namespace and queue name: Name of the service bus namespace. queue_name: Name of the service bus queue in this namespace.'
def get_supported_metrics_queue(self, name, queue_name):
response = self._perform_get(self._get_get_supported_metrics_queue_path(name, queue_name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricProperties))
'Retrieves the list of supported metrics for this namespace and topic name: Name of the service bus namespace. topic_name: Name of the service bus queue in this namespace.'
def get_supported_metrics_topic(self, name, topic_name):
response = self._perform_get(self._get_get_supported_metrics_topic_path(name, topic_name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricProperties))
'Retrieves the list of supported metrics for this namespace and topic name: Name of the service bus namespace. hub_name: Name of the service bus notification hub in this namespace.'
def get_supported_metrics_notification_hub(self, name, hub_name):
response = self._perform_get(self._get_get_supported_metrics_hub_path(name, hub_name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricProperties))
'Retrieves the list of supported metrics for this namespace and relay name: Name of the service bus namespace. relay_name: Name of the service bus relay in this namespace.'
def get_supported_metrics_relay(self, name, relay_name):
response = self._perform_get(self._get_get_supported_metrics_relay_path(name, relay_name), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricProperties))
'Retrieves the list of supported metrics for this namespace and queue name: Name of the service bus namespace. queue_name: Name of the service bus queue in this namespace. metric: name of a supported metric rollup: name of a supported rollup filter_expression: filter, for instance "$filter=Timestamp gt datetime\'2014-1...
def get_metrics_data_queue(self, name, queue_name, metric, rollup, filter_expresssion):
response = self._perform_get(self._get_get_metrics_data_queue_path(name, queue_name, metric, rollup, filter_expresssion), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricValues))
'Retrieves the list of supported metrics for this namespace and topic name: Name of the service bus namespace. topic_name: Name of the service bus queue in this namespace. metric: name of a supported metric rollup: name of a supported rollup filter_expression: filter, for instance "$filter=Timestamp gt datetime\'2014-1...
def get_metrics_data_topic(self, name, topic_name, metric, rollup, filter_expresssion):
response = self._perform_get(self._get_get_metrics_data_topic_path(name, topic_name, metric, rollup, filter_expresssion), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricValues))
'Retrieves the list of supported metrics for this namespace and topic name: Name of the service bus namespace. hub_name: Name of the service bus notification hub in this namespace. metric: name of a supported metric rollup: name of a supported rollup filter_expression: filter, for instance "$filter=Timestamp gt datetim...
def get_metrics_data_notification_hub(self, name, hub_name, metric, rollup, filter_expresssion):
response = self._perform_get(self._get_get_metrics_data_hub_path(name, hub_name, metric, rollup, filter_expresssion), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricValues))
'Retrieves the list of supported metrics for this namespace and relay name: Name of the service bus namespace. relay_name: Name of the service bus relay in this namespace. metric: name of a supported metric rollup: name of a supported rollup filter_expression: filter, for instance "$filter=Timestamp gt datetime\'2014-1...
def get_metrics_data_relay(self, name, relay_name, metric, rollup, filter_expresssion):
response = self._perform_get(self._get_get_metrics_data_relay_path(name, relay_name, metric, rollup, filter_expresssion), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricValues))
'This operation gets rollup data for Service Bus metrics queue. Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity. name: Name of the service bus namespace. queue_name: Name of the service bus queue in this namespace. metric: name of a sup...
def get_metrics_rollups_queue(self, name, queue_name, metric):
response = self._perform_get(self._get_get_metrics_rollup_queue_path(name, queue_name, metric), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricRollups))
'This operation gets rollup data for Service Bus metrics topic. Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity. name: Name of the service bus namespace. topic_name: Name of the service bus queue in this namespace. metric: name of a sup...
def get_metrics_rollups_topic(self, name, topic_name, metric):
response = self._perform_get(self._get_get_metrics_rollup_topic_path(name, topic_name, metric), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricRollups))
'This operation gets rollup data for Service Bus metrics notification hub. Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity. name: Name of the service bus namespace. hub_name: Name of the service bus notification hub in this namespace. m...
def get_metrics_rollups_notification_hub(self, name, hub_name, metric):
response = self._perform_get(self._get_get_metrics_rollup_hub_path(name, hub_name, metric), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricRollups))
'This operation gets rollup data for Service Bus metrics relay. Rollup data includes the time granularity for the telemetry aggregation as well as the retention settings for each time granularity. name: Name of the service bus namespace. relay_name: Name of the service bus relay in this namespace. metric: name of a sup...
def get_metrics_rollups_relay(self, name, relay_name, metric):
response = self._perform_get(self._get_get_metrics_rollup_relay_path(name, relay_name, metric), None) return _MinidomXmlToObject.convert_response_to_feeds(response, partial(_ServiceBusManagementXmlSerializer.xml_to_metrics, object_type=MetricRollups))
'Initializes the management service. subscription_id: Subscription to manage. cert_file: Path to .pem certificate file (httplib), or location of the certificate in your Personal certificate store (winhttp) in the CURRENT_USER\my\CertificateName format. If a request_session is specified, then this is unused. host: Live ...
def __init__(self, subscription_id=None, cert_file=None, host=MANAGEMENT_HOST, request_session=None, timeout=DEFAULT_HTTP_TIMEOUT):
super(ServiceManagementService, self).__init__(subscription_id, cert_file, host, request_session, timeout)
'Lists the role sizes that are available under the specified subscription.'
def list_role_sizes(self):
return self._perform_get(self._get_role_sizes_path(), RoleSizes)
'Returns a list of subscriptions that you can access. You must make sure that the request that is made to the management service is secure using an Active Directory access token.'
def list_subscriptions(self):
return self._perform_get(self._get_subscriptions_path(), Subscriptions)
'Lists the storage accounts available under the current subscription.'
def list_storage_accounts(self):
return self._perform_get(self._get_storage_service_path(), StorageServices)
'Returns system properties for the specified storage account. service_name: Name of the storage service account.'
def get_storage_account_properties(self, service_name):
_validate_not_none('service_name', service_name) return self._perform_get(self._get_storage_service_path(service_name), StorageService)
'Returns the primary and secondary access keys for the specified storage account. service_name: Name of the storage service account.'
def get_storage_account_keys(self, service_name):
_validate_not_none('service_name', service_name) return self._perform_get((self._get_storage_service_path(service_name) + '/keys'), StorageService)
'Regenerates the primary or secondary access key for the specified storage account. service_name: Name of the storage service account. key_type: Specifies which key to regenerate. Valid values are: Primary, Secondary'
def regenerate_storage_account_keys(self, service_name, key_type):
_validate_not_none('service_name', service_name) _validate_not_none('key_type', key_type) return self._perform_post((self._get_storage_service_path(service_name) + '/keys?action=regenerate'), _XmlSerializer.regenerate_keys_to_xml(key_type), StorageService)
'Creates a new storage account in Windows Azure. service_name: A name for the storage account that is unique within Windows Azure. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. description: A description for the storage account. The description may be u...
def create_storage_account(self, service_name, description, label, affinity_group=None, location=None, geo_replication_enabled=None, extended_properties=None, account_type='Standard_GRS'):
_validate_not_none('service_name', service_name) _validate_not_none('description', description) _validate_not_none('label', label) if ((affinity_group is None) and (location is None)): raise ValueError('location or affinity_group must be specified') if ((affinity_group is not ...
'Updates the label, the description, and enables or disables the geo-replication status for a storage account in Windows Azure. service_name: Name of the storage service account. description: A description for the storage account. The description may be up to 1024 characters in length. label: A name for the storage acc...
def update_storage_account(self, service_name, description=None, label=None, geo_replication_enabled=None, extended_properties=None, account_type='Standard_GRS'):
_validate_not_none('service_name', service_name) if (geo_replication_enabled == False): account_type = 'Standard_LRS' return self._perform_put(self._get_storage_service_path(service_name), _XmlSerializer.update_storage_service_input_to_xml(description, label, account_type, extended_properties))
'Deletes the specified storage account from Windows Azure. service_name: Name of the storage service account.'
def delete_storage_account(self, service_name):
_validate_not_none('service_name', service_name) return self._perform_delete(self._get_storage_service_path(service_name), async=True)
'Checks to see if the specified storage account name is available, or if it has already been taken. service_name: Name of the storage service account.'
def check_storage_account_name_availability(self, service_name):
_validate_not_none('service_name', service_name) return self._perform_get((((self._get_storage_service_path() + '/operations/isavailable/') + _str(service_name)) + ''), AvailabilityResponse)
'Lists the hosted services available under the current subscription. Note that you will receive a list of HostedService instances, without all details inside. For instance, deployments will be None. If you want deployments information for a specific host service, you have to call get_hosted_service_properties with embe...
def list_hosted_services(self):
return self._perform_get(self._get_hosted_service_path(), HostedServices)
'Retrieves system properties for the specified hosted service. These properties include the service name and service type; the name of the affinity group to which the service belongs, or its location if it is not part of an affinity group; and optionally, information on the service\'s deployments. service_name: Name of...
def get_hosted_service_properties(self, service_name, embed_detail=False):
_validate_not_none('service_name', service_name) _validate_not_none('embed_detail', embed_detail) return self._perform_get(((self._get_hosted_service_path(service_name) + '?embed-detail=') + _str(embed_detail).lower()), HostedService)
'Creates a new hosted service in Windows Azure. service_name: A name for the hosted service that is unique within Windows Azure. This name is the DNS prefix name and can be used to access the hosted service. label: A name for the hosted service. The name can be up to 100 characters in length. The name can be used to id...
def create_hosted_service(self, service_name, label, description=None, location=None, affinity_group=None, extended_properties=None):
_validate_not_none('service_name', service_name) _validate_not_none('label', label) if ((affinity_group is None) and (location is None)): raise ValueError('location or affinity_group must be specified') if ((affinity_group is not None) and (location is not None)): raise Va...
'Updates the label and/or the description for a hosted service in Windows Azure. service_name: Name of the hosted service. label: A name for the hosted service. The name may be up to 100 characters in length. You must specify a value for either Label or Description, or for both. It is recommended that the label be uniq...
def update_hosted_service(self, service_name, label=None, description=None, extended_properties=None):
_validate_not_none('service_name', service_name) return self._perform_put(self._get_hosted_service_path(service_name), _XmlSerializer.update_hosted_service_to_xml(label, description, extended_properties))
'Deletes the specified hosted service from Windows Azure. service_name: Name of the hosted service. complete: True if all OS/data disks and the source blobs for the disks should also be deleted from storage.'
def delete_hosted_service(self, service_name, complete=False):
_validate_not_none('service_name', service_name) path = self._get_hosted_service_path(service_name) if (complete == True): path = (path + '?comp=media') return self._perform_delete(path, async=True)
'Returns configuration information, status, and system properties for a deployment. service_name: Name of the hosted service. deployment_slot: The environment to which the hosted service is deployed. Valid values are: staging, production'
def get_deployment_by_slot(self, service_name, deployment_slot):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_slot', deployment_slot) return self._perform_get(self._get_deployment_path_using_slot(service_name, deployment_slot), Deployment)
'Returns configuration information, status, and system properties for a deployment. service_name: Name of the hosted service. deployment_name: The name of the deployment.'
def get_deployment_by_name(self, service_name, deployment_name):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) return self._perform_get(self._get_deployment_path_using_name(service_name, deployment_name), Deployment)
'Uploads a new service package and creates a new deployment on staging or production. service_name: Name of the hosted service. deployment_slot: The environment to which the hosted service is deployed. Valid values are: staging, production name: The name for the deployment. The deployment name must be unique among othe...
def create_deployment(self, service_name, deployment_slot, name, package_url, label, configuration, start_deployment=False, treat_warnings_as_error=False, extended_properties=None):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_slot', deployment_slot) _validate_not_none('name', name) _validate_not_none('package_url', package_url) _validate_not_none('label', label) _validate_not_none('configuration', configuration) return self._perform_p...
'Deletes the specified deployment. service_name: Name of the hosted service. deployment_name: The name of the deployment.'
def delete_deployment(self, service_name, deployment_name, delete_vhd=False):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) path = self._get_deployment_path_using_name(service_name, deployment_name) if delete_vhd: path += '?comp=media' return self._perform_delete(path, async=True)
'Initiates a virtual IP swap between the staging and production deployment environments for a service. If the service is currently running in the staging environment, it will be swapped to the production environment. If it is running in the production environment, it will be swapped to staging. service_name: Name of th...
def swap_deployment(self, service_name, production, source_deployment):
_validate_not_none('service_name', service_name) _validate_not_none('production', production) _validate_not_none('source_deployment', source_deployment) return self._perform_post(self._get_hosted_service_path(service_name), _XmlSerializer.swap_deployment_to_xml(production, source_deployment), async=True...
'Initiates a change to the deployment configuration. service_name: Name of the hosted service. deployment_name: The name of the deployment. configuration: The base-64 encoded service configuration file for the deployment. treat_warnings_as_error: Indicates whether to treat package validation warnings as errors. If set ...
def change_deployment_configuration(self, service_name, deployment_name, configuration, treat_warnings_as_error=False, mode='Auto', extended_properties=None):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('configuration', configuration) return self._perform_post((self._get_deployment_path_using_name(service_name, deployment_name) + '/?comp=config'), _XmlSerializer.change_deployment_t...
'Initiates a change in deployment status. service_name: Name of the hosted service. deployment_name: The name of the deployment. status: The change to initiate to the deployment status. Possible values include: Running, Suspended'
def update_deployment_status(self, service_name, deployment_name, status):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('status', status) return self._perform_post((self._get_deployment_path_using_name(service_name, deployment_name) + '/?comp=status'), _XmlSerializer.update_deployment_status_to_xml(s...
'Initiates an upgrade. service_name: Name of the hosted service. deployment_name: The name of the deployment. mode: If set to Manual, WalkUpgradeDomain must be called to apply the update. If set to Auto, the Windows Azure platform will automatically apply the update To each upgrade domain for the service. Possible valu...
def upgrade_deployment(self, service_name, deployment_name, mode, package_url, configuration, label, force, role_to_upgrade=None, extended_properties=None):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('mode', mode) _validate_not_none('package_url', package_url) _validate_not_none('configuration', configuration) _validate_not_none('label', label) _validate_not_none('fo...
'Specifies the next upgrade domain to be walked during manual in-place upgrade or configuration change. service_name: Name of the hosted service. deployment_name: The name of the deployment. upgrade_domain: An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based ind...
def walk_upgrade_domain(self, service_name, deployment_name, upgrade_domain):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('upgrade_domain', upgrade_domain) return self._perform_post((self._get_deployment_path_using_name(service_name, deployment_name) + '/?comp=walkupgradedomain'), _XmlSerializer.walk_u...
'Cancels an in progress configuration change (update) or upgrade and returns the deployment to its state before the upgrade or configuration change was started. service_name: Name of the hosted service. deployment_name: The name of the deployment. mode: Specifies whether the rollback should proceed automatically. auto ...
def rollback_update_or_upgrade(self, service_name, deployment_name, mode, force):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('mode', mode) _validate_not_none('force', force) return self._perform_post((self._get_deployment_path_using_name(service_name, deployment_name) + '/?comp=rollback'), _XmlSeriali...
'Requests a reboot of a role instance that is running in a deployment. service_name: Name of the hosted service. deployment_name: The name of the deployment. role_instance_name: The name of the role instance.'
def reboot_role_instance(self, service_name, deployment_name, role_instance_name):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('role_instance_name', role_instance_name) return self._perform_post((((self._get_deployment_path_using_name(service_name, deployment_name) + '/roleinstances/') + _str(role_instance_...
'Requests a reimage of a role instance that is running in a deployment. service_name: Name of the hosted service. deployment_name: The name of the deployment. role_instance_name: The name of the role instance.'
def reimage_role_instance(self, service_name, deployment_name, role_instance_name):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('role_instance_name', role_instance_name) return self._perform_post((((self._get_deployment_path_using_name(service_name, deployment_name) + '/roleinstances/') + _str(role_instance_...
'Reinstalls the operating system on instances of web roles or worker roles and initializes the storage resources that are used by them. If you do not want to initialize storage resources, you can use reimage_role_instance. service_name: Name of the hosted service. deployment_name: The name of the deployment. role_insta...
def rebuild_role_instance(self, service_name, deployment_name, role_instance_name):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('role_instance_name', role_instance_name) return self._perform_post((((self._get_deployment_path_using_name(service_name, deployment_name) + '/roleinstances/') + _str(role_instance_...
'Reinstalls the operating system on instances of web roles or worker roles and initializes the storage resources that are used by them. If you do not want to initialize storage resources, you can use reimage_role_instance. service_name: Name of the hosted service. deployment_name: The name of the deployment. role_insta...
def delete_role_instances(self, service_name, deployment_name, role_instance_names):
_validate_not_none('service_name', service_name) _validate_not_none('deployment_name', deployment_name) _validate_not_none('role_instance_names', role_instance_names) return self._perform_post((self._get_deployment_path_using_name(service_name, deployment_name) + '/roleinstances/?comp=delete'), _XmlSeri...