_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q6500
OpenTok.stop_broadcast
train
def stop_broadcast(self, broadcast_id): """ Use this method to stop a live broadcast of an OpenTok session :param String broadcast_id: The ID of the broadcast you want to stop :rtype A Broadcast object, which contains information of the broadcast: id, sessionId projectId, createdAt, updatedAt and resolution """ endpoint = self.endpoints.broadcast_url(broadcast_id, stop=True) response = requests.post( endpoint, headers=self.json_headers(), proxies=self.proxies, timeout=self.timeout ) if response.status_code == 200: return Broadcast(response.json()) elif response.status_code == 400: raise BroadcastError( 'Invalid request. This response may indicate that data in your request ' 'data is invalid JSON.') elif response.status_code == 403: raise AuthError('Authentication error.') elif response.status_code == 409: raise BroadcastError( 'The broadcast (with the specified ID) was not found or it has already ' 'stopped.') else: raise RequestError('OpenTok server error.', response.status_code)
python
{ "resource": "" }
q6501
OpenTok.get_broadcast
train
def get_broadcast(self, broadcast_id): """ Use this method to get details on a broadcast that is in-progress. :param String broadcast_id: The ID of the broadcast you want to stop :rtype A Broadcast object, which contains information of the broadcast: id, sessionId projectId, createdAt, updatedAt, resolution, broadcastUrls and status """ endpoint = self.endpoints.broadcast_url(broadcast_id) response = requests.get( endpoint, headers=self.json_headers(), proxies=self.proxies, timeout=self.timeout ) if response.status_code == 200: return Broadcast(response.json()) elif response.status_code == 400: raise BroadcastError( 'Invalid request. This response may indicate that data in your request ' 'data is invalid JSON.') elif response.status_code == 403: raise AuthError('Authentication error.') elif response.status_code == 409: raise BroadcastError('No matching broadcast found (with the specified ID).') else: raise RequestError('OpenTok server error.', response.status_code)
python
{ "resource": "" }
q6502
OpenTok.set_broadcast_layout
train
def set_broadcast_layout(self, broadcast_id, layout_type, stylesheet=None): """ Use this method to change the layout type of a live streaming broadcast :param String broadcast_id: The ID of the broadcast that will be updated :param String layout_type: The layout type for the broadcast. Valid values are: 'bestFit', 'custom', 'horizontalPresentation', 'pip' and 'verticalPresentation' :param String stylesheet optional: CSS used to style the custom layout. Specify this only if you set the type property to 'custom' """ payload = { 'type': layout_type, } if layout_type == 'custom': if stylesheet is not None: payload['stylesheet'] = stylesheet endpoint = self.endpoints.broadcast_url(broadcast_id, layout=True) response = requests.put( endpoint, data=json.dumps(payload), headers=self.json_headers(), proxies=self.proxies, timeout=self.timeout ) if response.status_code == 200: pass elif response.status_code == 400: raise BroadcastError( 'Invalid request. This response may indicate that data in your request data is ' 'invalid JSON. It may also indicate that you passed in invalid layout options.') elif response.status_code == 403: raise AuthError('Authentication error.') else: raise RequestError('OpenTok server error.', response.status_code)
python
{ "resource": "" }
q6503
Instapaper.login
train
def login(self, username, password): '''Authenticate using XAuth variant of OAuth. :param str username: Username or email address for the relevant account :param str password: Password for the account ''' response = self.request( ACCESS_TOKEN, { 'x_auth_mode': 'client_auth', 'x_auth_username': username, 'x_auth_password': password }, returns_json=False ) token = dict(parse_qsl(response['data'].decode())) self.token = oauth.Token( token['oauth_token'], token['oauth_token_secret']) self.oauth_client = oauth.Client(self.consumer, self.token)
python
{ "resource": "" }
q6504
Instapaper.request
train
def request(self, path, params=None, returns_json=True, method='POST', api_version=API_VERSION): '''Process a request using the OAuth client's request method. :param str path: Path fragment to the API endpoint, e.g. "resource/ID" :param dict params: Parameters to pass to request :param str method: Optional HTTP method, normally POST for Instapaper :param str api_version: Optional alternative API version :returns: response headers and body :retval: dict ''' time.sleep(REQUEST_DELAY_SECS) full_path = '/'.join([BASE_URL, 'api/%s' % api_version, path]) params = urlencode(params) if params else None log.debug('URL: %s', full_path) request_kwargs = {'method': method} if params: request_kwargs['body'] = params response, content = self.oauth_client.request( full_path, **request_kwargs) log.debug('CONTENT: %s ...', content[:50]) if returns_json: try: data = json.loads(content) if isinstance(data, list) and len(data) == 1: # ugly -- API always returns a list even when you expect # only one item if data[0]['type'] == 'error': raise Exception('Instapaper error %d: %s' % ( data[0]['error_code'], data[0]['message']) ) # TODO: PyInstapaperException custom class? except ValueError: # Instapaper API can be unpredictable/inconsistent, e.g. # bookmarks/get_text doesn't return JSON data = content else: data = content return { 'response': response, 'data': data }
python
{ "resource": "" }
q6505
Instapaper.get_bookmarks
train
def get_bookmarks(self, folder='unread', limit=25, have=None): """Return list of user's bookmarks. :param str folder: Optional. Possible values are unread (default), starred, archive, or a folder_id value. :param int limit: Optional. A number between 1 and 500, default 25. :param list have: Optional. A list of IDs to exclude from results :returns: List of user's bookmarks :rtype: list """ path = 'bookmarks/list' params = {'folder_id': folder, 'limit': limit} if have: have_concat = ','.join(str(id_) for id_ in have) params['have'] = have_concat response = self.request(path, params) items = response['data'] bookmarks = [] for item in items: if item.get('type') == 'error': raise Exception(item.get('message')) elif item.get('type') == 'bookmark': bookmarks.append(Bookmark(self, **item)) return bookmarks
python
{ "resource": "" }
q6506
Instapaper.get_folders
train
def get_folders(self): """Return list of user's folders. :rtype: list """ path = 'folders/list' response = self.request(path) items = response['data'] folders = [] for item in items: if item.get('type') == 'error': raise Exception(item.get('message')) elif item.get('type') == 'folder': folders.append(Folder(self, **item)) return folders
python
{ "resource": "" }
q6507
InstapaperObject.add
train
def add(self): '''Save an object to Instapaper after instantiating it. Example:: folder = Folder(instapaper, title='stuff') result = folder.add() ''' # TODO validation per object type submit_attribs = {} for attrib in self.ATTRIBUTES: val = getattr(self, attrib, None) if val: submit_attribs[attrib] = val path = '/'.join([self.RESOURCE, 'add']) result = self.client.request(path, submit_attribs) return result
python
{ "resource": "" }
q6508
InstapaperObject._simple_action
train
def _simple_action(self, action=None): '''Issue a request for an API method whose only param is the obj ID. :param str action: The name of the action for the resource :returns: Response from the API :rtype: dict ''' if not action: raise Exception('No simple action defined') path = "/".join([self.RESOURCE, action]) response = self.client.request( path, {self.RESOURCE_ID_ATTRIBUTE: self.object_id} ) return response
python
{ "resource": "" }
q6509
Bookmark.get_highlights
train
def get_highlights(self): '''Get highlights for Bookmark instance. :return: list of ``Highlight`` objects :rtype: list ''' # NOTE: all Instapaper API methods use POST except this one! path = '/'.join([self.RESOURCE, str(self.object_id), 'highlights']) response = self.client.request(path, method='GET', api_version='1.1') items = response['data'] highlights = [] for item in items: if item.get('type') == 'error': raise Exception(item.get('message')) elif item.get('type') == 'highlight': highlights.append(Highlight(self, **item)) return highlights
python
{ "resource": "" }
q6510
Sender.build_message
train
def build_message(self, metric, value, timestamp, tags={}): """Build a Graphite message to send and return it as a byte string.""" if not metric or metric.split(None, 1)[0] != metric: raise ValueError('"metric" must not have whitespace in it') if not isinstance(value, (int, float)): raise TypeError('"value" must be an int or a float, not a {}'.format( type(value).__name__)) tags_suffix = ''.join(';{}={}'.format(x[0], x[1]) for x in sorted(tags.items())) message = u'{}{}{} {} {}\n'.format( self.prefix + '.' if self.prefix else '', metric, tags_suffix, value, int(round(timestamp)) ) message = message.encode('utf-8') return message
python
{ "resource": "" }
q6511
get_rg_from_id
train
def get_rg_from_id(vmss_id): '''get a resource group name from a VMSS ID string''' rgname = re.search('Groups/(.+?)/providers', vmss_id).group(1) print('Resource group: ' + rgname) return rgname
python
{ "resource": "" }
q6512
get_user_agent
train
def get_user_agent(): '''User-Agent Header. Sends library identification to Azure endpoint. ''' version = pkg_resources.require("azurerm")[0].version user_agent = "python/{} ({}) requests/{} azurerm/{}".format( platform.python_version(), platform.platform(), requests.__version__, version) return user_agent
python
{ "resource": "" }
q6513
do_get_next
train
def do_get_next(endpoint, access_token): '''Do an HTTP GET request, follow the nextLink chain and return JSON. Args: endpoint (str): Azure Resource Manager management endpoint. access_token (str): A valid Azure authentication token. Returns: HTTP response. JSON body. ''' headers = {"Authorization": 'Bearer ' + access_token} headers['User-Agent'] = get_user_agent() looping = True value_list = [] vm_dict = {} while looping: get_return = requests.get(endpoint, headers=headers).json() if not 'value' in get_return: return get_return if not 'nextLink' in get_return: looping = False else: endpoint = get_return['nextLink'] value_list += get_return['value'] vm_dict['value'] = value_list return vm_dict
python
{ "resource": "" }
q6514
do_patch
train
def do_patch(endpoint, body, access_token): '''Do an HTTP PATCH request and return JSON. Args: endpoint (str): Azure Resource Manager management endpoint. body (str): JSON body of information to patch. access_token (str): A valid Azure authentication token. Returns: HTTP response. JSON body. ''' headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token} headers['User-Agent'] = get_user_agent() return requests.patch(endpoint, data=body, headers=headers)
python
{ "resource": "" }
q6515
do_post
train
def do_post(endpoint, body, access_token): '''Do an HTTP POST request and return JSON. Args: endpoint (str): Azure Resource Manager management endpoint. body (str): JSON body of information to post. access_token (str): A valid Azure authentication token. Returns: HTTP response. JSON body. ''' headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token} headers['User-Agent'] = get_user_agent() return requests.post(endpoint, data=body, headers=headers)
python
{ "resource": "" }
q6516
do_put
train
def do_put(endpoint, body, access_token): '''Do an HTTP PUT request and return JSON. Args: endpoint (str): Azure Resource Manager management endpoint. body (str): JSON body of information to put. access_token (str): A valid Azure authentication token. Returns: HTTP response. JSON body. ''' headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token} headers['User-Agent'] = get_user_agent() return requests.put(endpoint, data=body, headers=headers)
python
{ "resource": "" }
q6517
handle_bad_update
train
def handle_bad_update(operation, ret): '''report error for bad update''' print("Error " + operation) sys.exit('Return code: ' + str(ret.status_code) + ' Error: ' + ret.text)
python
{ "resource": "" }
q6518
extract_code
train
def extract_code(end_mark, current_str, str_array, line_num): '''Extract a multi-line string from a string array, up to a specified end marker. Args: end_mark (str): The end mark string to match for. current_str (str): The first line of the string array. str_array (list): An array of strings (lines). line_num (int): The current offset into the array. Returns: Extended string up to line with end marker. ''' if end_mark not in current_str: reached_end = False line_num += 1 while reached_end is False: next_line = str_array[line_num] if end_mark in next_line: reached_end = True else: line_num += 1 current_str += next_line clean_str = current_str.split(end_mark)[0] return {'current_str': clean_str, 'line_num': line_num}
python
{ "resource": "" }
q6519
process_output
train
def process_output(meta_file, outfile_name, code_links): '''Create a markdown format documentation file. Args: meta_file (dict): Dictionary with documentation metadata. outfile_name (str): Markdown file to write to. ''' # Markdown title line doc_str = '# ' + meta_file['header'] + '\n' doc_str += 'Generated by [py2md](https://github.com/gbowerman/py2md) on ' doc_str += strftime("%Y-%m-%d %H:%M:%S ") + '\n\n' # Create a table of contents if more than one module (i.e. more than one # source file) if len(meta_file['modules']) > 1: doc_str += "## Contents\n" chapter_num = 1 for meta_doc in meta_file['modules']: chapter_name = meta_doc['summary_comment'] chapter_link = chapter_name.lstrip().replace('.', '').replace(' ', '-').lower() doc_str += str(chapter_num) + \ '. [' + chapter_name + '](#' + chapter_link + ')\n' chapter_num += 1 # Document each meta-file for meta_doc in meta_file['modules']: doc_str += '## ' + meta_doc['summary_comment'] + '\n' doc_str += '[source file](' + meta_doc['source_file'] + ')' + '\n' for function_info in meta_doc['functions']: doc_str += '### ' + function_info['name'] + '\n' doc_str += function_info['definition'] + '\n\n' if 'comments' in function_info: doc_str += '```\n' + function_info['comments'] + '\n```\n\n' # write the markdown to file print('Writing file: ' + outfile_name) out_file = open(outfile_name, 'w') out_file.write(doc_str) out_file.close()
python
{ "resource": "" }
q6520
create_container_service
train
def create_container_service(access_token, subscription_id, resource_group, service_name, \ agent_count, agent_vm_size, agent_dns, master_dns, admin_user, location, public_key=None,\ master_count=3, orchestrator='DCOS', app_id=None, app_secret=None, admin_password=None, \ ostype='Linux'): '''Create a new container service - include app_id and app_secret if using Kubernetes. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. service_name (str): Name of container service. agent_count (int): The number of agent VMs. agent_vm_size (str): VM size of agents, e.g. Standard_D1_v2. agent_dns (str): A unique DNS string for the agent DNS. master_dns (str): A unique string for the master DNS. admin_user (str): Admin user name. location (str): Azure data center location, e.g. westus. public_key (str): RSA public key (utf-8). master_count (int): Number of master VMs. orchestrator (str): Container orchestrator. E.g. DCOS, Kubernetes. app_id (str): Application ID for Kubernetes. app_secret (str): Application secret for Kubernetes. admin_password (str): Admin user password. ostype (str): Operating system. Windows of Linux. Returns: HTTP response. Container service JSON model. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', resource_group, '/providers/Microsoft.ContainerService/ContainerServices/', service_name, '?api-version=', ACS_API]) acs_body = {'location': location} properties = {'orchestratorProfile': {'orchestratorType': orchestrator}} properties['masterProfile'] = {'count': master_count, 'dnsPrefix': master_dns} ap_profile = {'name': 'AgentPool1'} ap_profile['count'] = agent_count ap_profile['vmSize'] = agent_vm_size ap_profile['dnsPrefix'] = agent_dns properties['agentPoolProfiles'] = [ap_profile] if ostype == 'Linux': linux_profile = {'adminUsername': admin_user} linux_profile['ssh'] = {'publicKeys': [{'keyData': public_key}]} properties['linuxProfile'] = linux_profile else: # Windows windows_profile = {'adminUsername': admin_user, 'adminPassword': admin_password} properties['windowsProfile'] = windows_profile if orchestrator == 'Kubernetes': sp_profile = {'ClientID': app_id} sp_profile['Secret'] = app_secret properties['servicePrincipalProfile'] = sp_profile acs_body['properties'] = properties body = json.dumps(acs_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6521
delete_container_service
train
def delete_container_service(access_token, subscription_id, resource_group, service_name): '''Delete a named container. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. service_name (str): Name of container service. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', resource_group, '/providers/Microsoft.ContainerService/ContainerServices/', service_name, '?api-version=', ACS_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6522
get_container_service
train
def get_container_service(access_token, subscription_id, resource_group, service_name): '''Get details about an Azure Container Server Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. service_name (str): Name of container service. Returns: HTTP response. JSON model. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', resource_group, '/providers/Microsoft.ContainerService/ContainerServices/', service_name, '?api-version=', ACS_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6523
list_container_services
train
def list_container_services(access_token, subscription_id, resource_group): '''List the container services in a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. Returns: HTTP response. JSON model. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', resource_group, '/providers/Microsoft.ContainerService/ContainerServices', '?api-version=', ACS_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6524
list_container_services_sub
train
def list_container_services_sub(access_token, subscription_id): '''List the container services in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON model. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.ContainerService/ContainerServices', '?api-version=', ACS_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6525
create_storage_account
train
def create_storage_account(access_token, subscription_id, rgname, account_name, location, storage_type='Standard_LRS'): '''Create a new storage account in the named resource group, with the named location. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. account_name (str): Name of the new storage account. location (str): Azure data center location. E.g. westus. storage_type (str): Premium or Standard, local or globally redundant. Defaults to Standard_LRS. Returns: HTTP response. JSON body of storage account properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', rgname, '/providers/Microsoft.Storage/storageAccounts/', account_name, '?api-version=', STORAGE_API]) storage_body = {'location': location} storage_body['sku'] = {'name': storage_type} storage_body['kind'] = 'Storage' body = json.dumps(storage_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6526
delete_storage_account
train
def delete_storage_account(access_token, subscription_id, rgname, account_name): '''Delete a storage account in the specified resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. account_name (str): Name of the new storage account. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', rgname, '/providers/Microsoft.Storage/storageAccounts/', account_name, '?api-version=', STORAGE_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6527
get_storage_account
train
def get_storage_account(access_token, subscription_id, rgname, account_name): '''Get the properties for the named storage account. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. account_name (str): Name of the new storage account. Returns: HTTP response. JSON body of storage account properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', rgname, '/providers/Microsoft.Storage/storageAccounts/', account_name, '?api-version=', STORAGE_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6528
get_storage_account_keys
train
def get_storage_account_keys(access_token, subscription_id, rgname, account_name): '''Get the access keys for the specified storage account. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. account_name (str): Name of the new storage account. Returns: HTTP response. JSON body of storage account keys. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', rgname, '/providers/Microsoft.Storage/storageAccounts/', account_name, '/listKeys', '?api-version=', STORAGE_API]) return do_post(endpoint, '', access_token)
python
{ "resource": "" }
q6529
get_storage_usage
train
def get_storage_usage(access_token, subscription_id, location): '''Returns storage usage and quota information for the specified subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of storage account usage. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Storage/locations/', location, '/usages', '?api-version=', STORAGE_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6530
list_storage_accounts_rg
train
def list_storage_accounts_rg(access_token, subscription_id, rgname): '''List the storage accounts in the specified resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. Returns: HTTP response. JSON body list of storage accounts. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', rgname, '/providers/Microsoft.Storage/storageAccounts', '?api-version=', STORAGE_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6531
list_storage_accounts_sub
train
def list_storage_accounts_sub(access_token, subscription_id): '''List the storage accounts in the specified subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body list of storage accounts. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Storage/storageAccounts', '?api-version=', STORAGE_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6532
rgfromid
train
def rgfromid(idstr): '''get resource group name from the id string''' rgidx = idstr.find('resourceGroups/') providx = idstr.find('/providers/') return idstr[rgidx + 15:providx]
python
{ "resource": "" }
q6533
check_media_service_name_availability
train
def check_media_service_name_availability(access_token, subscription_id, msname): '''Check media service name availability. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. msname (str): media service name. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/microsoft.media/CheckNameAvailability?', 'api-version=', MEDIA_API]) ms_body = {'name': msname} ms_body['type'] = 'mediaservices' body = json.dumps(ms_body) return do_post(endpoint, body, access_token)
python
{ "resource": "" }
q6534
create_media_service_rg
train
def create_media_service_rg(access_token, subscription_id, rgname, location, stoname, msname): '''Create a media service in a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. location (str): Azure data center location. E.g. westus. stoname (str): Azure storage account name. msname (str): Media service name. Returns: HTTP response. JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', rgname, '/providers/microsoft.media/mediaservices/', msname, '?api-version=', MEDIA_API]) ms_body = {'name': msname} ms_body['location'] = location sub_id_str = '/subscriptions/' + subscription_id + '/resourceGroups/' + rgname + \ '/providers/Microsoft.Storage/storageAccounts/' + stoname storage_account = {'id': sub_id_str} storage_account['isPrimary'] = True properties = {'storageAccounts': [storage_account]} ms_body['properties'] = properties body = json.dumps(ms_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6535
delete_media_service_rg
train
def delete_media_service_rg(access_token, subscription_id, rgname, msname): '''Delete a media service. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. msname (str): Media service name. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', rgname, '/providers/microsoft.media/mediaservices/', msname, '?api-version=', MEDIA_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6536
list_media_endpoint_keys
train
def list_media_endpoint_keys(access_token, subscription_id, rgname, msname): '''list the media endpoint keys in a media service Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. msname (str): Media service name. Returns: HTTP response. JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', rgname, '/providers/microsoft.media/', '/mediaservices/', msname, '/listKeys?api-version=', MEDIA_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6537
list_media_services
train
def list_media_services(access_token, subscription_id): '''List the media services in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/microsoft.media/mediaservices?api-version=', MEDIA_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6538
list_media_services_rg
train
def list_media_services_rg(access_token, subscription_id, rgname): '''List the media services in a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. Returns: HTTP response. JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', rgname, '/providers/microsoft.media/mediaservices?api-version=', MEDIA_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6539
get_ams_access_token
train
def get_ams_access_token(accountname, accountkey): '''Get Media Services Authentication Token. Args: accountname (str): Azure Media Services account name. accountkey (str): Azure Media Services Key. Returns: HTTP response. JSON body. ''' accountkey_encoded = urllib.parse.quote(accountkey, safe='') body = "grant_type=client_credentials&client_id=" + accountname + \ "&client_secret=" + accountkey_encoded + " &scope=urn%3aWindowsAzureMediaServices" return do_ams_auth(ams_auth_endpoint, body)
python
{ "resource": "" }
q6540
create_media_asset
train
def create_media_asset(access_token, name, options="0"): '''Create Media Service Asset. Args: access_token (str): A valid Azure authentication token. name (str): Media Service Asset Name. options (str): Media Service Options. Returns: HTTP response. JSON body. ''' path = '/Assets' endpoint = ''.join([ams_rest_endpoint, path]) body = '{"Name": "' + name + '", "Options": "' + str(options) + '"}' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6541
create_media_assetfile
train
def create_media_assetfile(access_token, parent_asset_id, name, is_primary="false", \ is_encrypted="false", encryption_scheme="None", encryptionkey_id="None"): '''Create Media Service Asset File. Args: access_token (str): A valid Azure authentication token. parent_asset_id (str): Media Service Parent Asset ID. name (str): Media Service Asset Name. is_primary (str): Media Service Primary Flag. is_encrypted (str): Media Service Encryption Flag. encryption_scheme (str): Media Service Encryption Scheme. encryptionkey_id (str): Media Service Encryption Key ID. Returns: HTTP response. JSON body. ''' path = '/Files' endpoint = ''.join([ams_rest_endpoint, path]) if encryption_scheme == "StorageEncryption": body = '{ \ "IsEncrypted": "' + is_encrypted + '", \ "EncryptionScheme": "' + encryption_scheme + '", \ "EncryptionVersion": "' + "1.0" + '", \ "EncryptionKeyId": "' + encryptionkey_id + '", \ "IsPrimary": "' + is_primary + '", \ "MimeType": "video/mp4", \ "Name": "' + name + '", \ "ParentAssetId": "' + parent_asset_id + '" \ }' else: body = '{ \ "IsPrimary": "' + is_primary + '", \ "MimeType": "video/mp4", \ "Name": "' + name + '", \ "ParentAssetId": "' + parent_asset_id + '" \ }' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6542
create_sas_locator
train
def create_sas_locator(access_token, asset_id, accesspolicy_id): '''Create Media Service SAS Locator. Args: access_token (str): A valid Azure authentication token. asset_id (str): Media Service Asset ID. accesspolicy_id (str): Media Service Access Policy ID. Returns: HTTP response. JSON body. ''' path = '/Locators' endpoint = ''.join([ams_rest_endpoint, path]) body = '{ \ "AccessPolicyId":"' + accesspolicy_id + '", \ "AssetId":"' + asset_id + '", \ "Type":1 \ }' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6543
create_asset_delivery_policy
train
def create_asset_delivery_policy(access_token, ams_account, key_delivery_url): '''Create Media Service Asset Delivery Policy. Args: access_token (str): A valid Azure authentication token. ams_account (str): Media Service Account. Returns: HTTP response. JSON body. ''' path = '/AssetDeliveryPolicies' endpoint = ''.join([ams_rest_endpoint, path]) body = '{ \ "Name":"AssetDeliveryPolicy", \ "AssetDeliveryProtocol":"4", \ "AssetDeliveryPolicyType":"3", \ "AssetDeliveryConfiguration":"[{ \ \\"Key\\":\\"2\\", \ \\"Value\\":\\"' + key_delivery_url + '\\"}]" \ }' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6544
create_contentkey_authorization_policy
train
def create_contentkey_authorization_policy(access_token, content): '''Create Media Service Content Key Authorization Policy. Args: access_token (str): A valid Azure authentication token. content (str): Content Payload. Returns: HTTP response. JSON body. ''' path = '/ContentKeyAuthorizationPolicies' endpoint = ''.join([ams_rest_endpoint, path]) body = content return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6545
create_contentkey_authorization_policy_options
train
def create_contentkey_authorization_policy_options(access_token, key_delivery_type="2", \ name="HLS Open Authorization Policy", key_restriction_type="0"): '''Create Media Service Content Key Authorization Policy Options. Args: access_token (str): A valid Azure authentication token. key_delivery_type (str): A Media Service Content Key Authorization Policy Delivery Type. name (str): A Media Service Contenty Key Authorization Policy Name. key_restiction_type (str): A Media Service Contenty Key Restriction Type. Returns: HTTP response. JSON body. ''' path = '/ContentKeyAuthorizationPolicyOptions' endpoint = ''.join([ams_rest_endpoint, path]) body = '{ \ "Name":"policy",\ "KeyDeliveryType":"' + key_delivery_type + '", \ "KeyDeliveryConfiguration":"", \ "Restrictions":[{ \ "Name":"' + name + '", \ "KeyRestrictionType":"' + key_restriction_type + '", \ "Requirements":null \ }] \ }' return do_ams_post(endpoint, path, body, access_token, "json_only")
python
{ "resource": "" }
q6546
create_ondemand_streaming_locator
train
def create_ondemand_streaming_locator(access_token, encoded_asset_id, pid, starttime=None): '''Create Media Service OnDemand Streaming Locator. Args: access_token (str): A valid Azure authentication token. encoded_asset_id (str): A Media Service Encoded Asset ID. pid (str): A Media Service Encoded PID. starttime (str): A Media Service Starttime. Returns: HTTP response. JSON body. ''' path = '/Locators' endpoint = ''.join([ams_rest_endpoint, path]) if starttime is None: body = '{ \ "AccessPolicyId":"' + pid + '", \ "AssetId":"' + encoded_asset_id + '", \ "Type": "2" \ }' else: body = '{ \ "AccessPolicyId":"' + pid + '", \ "AssetId":"' + encoded_asset_id + '", \ "StartTime":"' + str(starttime) + '", \ "Type": "2" \ }' return do_ams_post(endpoint, path, body, access_token, "json_only")
python
{ "resource": "" }
q6547
create_asset_accesspolicy
train
def create_asset_accesspolicy(access_token, name, duration, permission="1"): '''Create Media Service Asset Access Policy. Args: access_token (str): A valid Azure authentication token. name (str): A Media Service Asset Access Policy Name. duration (str): A Media Service duration. permission (str): A Media Service permission. Returns: HTTP response. JSON body. ''' path = '/AccessPolicies' endpoint = ''.join([ams_rest_endpoint, path]) body = '{ \ "Name": "' + str(name) + '", \ "DurationInMinutes": "' + duration + '", \ "Permissions": "' + permission + '" \ }' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6548
create_streaming_endpoint
train
def create_streaming_endpoint(access_token, name, description="New Streaming Endpoint", \ scale_units="1"): '''Create Media Service Streaming Endpoint. Args: access_token (str): A valid Azure authentication token. name (str): A Media Service Streaming Endpoint Name. description (str): A Media Service Streaming Endpoint Description. scale_units (str): A Media Service Scale Units Number. Returns: HTTP response. JSON body. ''' path = '/StreamingEndpoints' endpoint = ''.join([ams_rest_endpoint, path]) body = '{ \ "Id":null, \ "Name":"' + name + '", \ "Description":"' + description + '", \ "Created":"0001-01-01T00:00:00", \ "LastModified":"0001-01-01T00:00:00", \ "State":null, \ "HostName":null, \ "ScaleUnits":"' + scale_units + '", \ "CrossSiteAccessPolicies":{ \ "ClientAccessPolicy":"<access-policy><cross-domain-access><policy><allow-from http-request-headers=\\"*\\"><domain uri=\\"http://*\\" /></allow-from><grant-to><resource path=\\"/\\" include-subpaths=\\"false\\" /></grant-to></policy></cross-domain-access></access-policy>", \ "CrossDomainPolicy":"<?xml version=\\"1.0\\"?><!DOCTYPE cross-domain-policy SYSTEM \\"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\\"><cross-domain-policy><allow-access-from domain=\\"*\\" /></cross-domain-policy>" \ } \ }' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6549
scale_streaming_endpoint
train
def scale_streaming_endpoint(access_token, streaming_endpoint_id, scale_units): '''Scale Media Service Streaming Endpoint. Args: access_token (str): A valid Azure authentication token. streaming_endpoint_id (str): A Media Service Streaming Endpoint ID. scale_units (str): A Media Service Scale Units Number. Returns: HTTP response. JSON body. ''' path = '/StreamingEndpoints' full_path = ''.join([path, "('", streaming_endpoint_id, "')", "/Scale"]) full_path_encoded = urllib.parse.quote(full_path, safe='') endpoint = ''.join([ams_rest_endpoint, full_path_encoded]) body = '{"scaleUnits": "' + str(scale_units) + '"}' return do_ams_post(endpoint, full_path_encoded, body, access_token)
python
{ "resource": "" }
q6550
link_asset_content_key
train
def link_asset_content_key(access_token, asset_id, encryptionkey_id, ams_redirected_rest_endpoint): '''Link Media Service Asset and Content Key. Args: access_token (str): A valid Azure authentication token. asset_id (str): A Media Service Asset ID. encryption_id (str): A Media Service Encryption ID. ams_redirected_rest_endpoint (str): A Media Service Redirected Endpoint. Returns: HTTP response. JSON body. ''' path = '/Assets' full_path = ''.join([path, "('", asset_id, "')", "/$links/ContentKeys"]) full_path_encoded = urllib.parse.quote(full_path, safe='') endpoint = ''.join([ams_rest_endpoint, full_path_encoded]) uri = ''.join([ams_redirected_rest_endpoint, 'ContentKeys', "('", encryptionkey_id, "')"]) body = '{"uri": "' + uri + '"}' return do_ams_post(endpoint, full_path_encoded, body, access_token)
python
{ "resource": "" }
q6551
link_contentkey_authorization_policy
train
def link_contentkey_authorization_policy(access_token, ckap_id, options_id, \ ams_redirected_rest_endpoint): '''Link Media Service Content Key Authorization Policy. Args: access_token (str): A valid Azure authentication token. ckap_id (str): A Media Service Asset Content Key Authorization Policy ID. options_id (str): A Media Service Content Key Authorization Policy Options . ams_redirected_rest_endpoint (str): A Media Service Redirected Endpoint. Returns: HTTP response. JSON body. ''' path = '/ContentKeyAuthorizationPolicies' full_path = ''.join([path, "('", ckap_id, "')", "/$links/Options"]) full_path_encoded = urllib.parse.quote(full_path, safe='') endpoint = ''.join([ams_rest_endpoint, full_path_encoded]) uri = ''.join([ams_redirected_rest_endpoint, 'ContentKeyAuthorizationPolicyOptions', \ "('", options_id, "')"]) body = '{"uri": "' + uri + '"}' return do_ams_post(endpoint, full_path_encoded, body, access_token, "json_only", "1.0;NetFx")
python
{ "resource": "" }
q6552
add_authorization_policy
train
def add_authorization_policy(access_token, ck_id, oid): '''Add Media Service Authorization Policy. Args: access_token (str): A valid Azure authentication token. ck_id (str): A Media Service Asset Content Key ID. options_id (str): A Media Service OID. Returns: HTTP response. JSON body. ''' path = '/ContentKeys' body = '{"AuthorizationPolicyId":"' + oid + '"}' return helper_add(access_token, ck_id, path, body)
python
{ "resource": "" }
q6553
update_media_assetfile
train
def update_media_assetfile(access_token, parent_asset_id, asset_id, content_length, name): '''Update Media Service Asset File. Args: access_token (str): A valid Azure authentication token. parent_asset_id (str): A Media Service Asset Parent Asset ID. asset_id (str): A Media Service Asset Asset ID. content_length (str): A Media Service Asset Content Length. name (str): A Media Service Asset name. Returns: HTTP response. JSON body. ''' path = '/Files' full_path = ''.join([path, "('", asset_id, "')"]) full_path_encoded = urllib.parse.quote(full_path, safe='') endpoint = ''.join([ams_rest_endpoint, full_path_encoded]) body = '{ \ "ContentFileSize": "' + str(content_length) + '", \ "Id": "' + asset_id + '", \ "MimeType": "video/mp4", \ "Name": "' + name + '", \ "ParentAssetId": "' + parent_asset_id + '" \ }' return do_ams_patch(endpoint, full_path_encoded, body, access_token)
python
{ "resource": "" }
q6554
get_key_delivery_url
train
def get_key_delivery_url(access_token, ck_id, key_type): '''Get Media Services Key Delivery URL. Args: access_token (str): A valid Azure authentication token. ck_id (str): A Media Service Content Key ID. key_type (str): A Media Service key Type. Returns: HTTP response. JSON body. ''' path = '/ContentKeys' full_path = ''.join([path, "('", ck_id, "')", "/GetKeyDeliveryUrl"]) endpoint = ''.join([ams_rest_endpoint, full_path]) body = '{"keyDeliveryType": "' + key_type + '"}' return do_ams_post(endpoint, full_path, body, access_token)
python
{ "resource": "" }
q6555
encode_mezzanine_asset
train
def encode_mezzanine_asset(access_token, processor_id, asset_id, output_assetname, json_profile): '''Get Media Service Encode Mezanine Asset. Args: access_token (str): A valid Azure authentication token. processor_id (str): A Media Service Processor ID. asset_id (str): A Media Service Asset ID. output_assetname (str): A Media Service Asset Name. json_profile (str): A Media Service JSON Profile. Returns: HTTP response. JSON body. ''' path = '/Jobs' endpoint = ''.join([ams_rest_endpoint, path]) assets_path = ''.join(["/Assets", "('", asset_id, "')"]) assets_path_encoded = urllib.parse.quote(assets_path, safe='') endpoint_assets = ''.join([ams_rest_endpoint, assets_path_encoded]) body = '{ \ "Name":"' + output_assetname + '", \ "InputMediaAssets":[{ \ "__metadata":{ \ "uri":"' + endpoint_assets + '" \ } \ }], \ "Tasks":[{ \ "Configuration":\'' + json_profile + '\', \ "MediaProcessorId":"' + processor_id + '", \ "TaskBody":"<?xml version=\\"1.0\\" encoding=\\"utf-16\\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset assetCreationOptions=\\"0\\" assetName=\\"' + output_assetname + '\\">JobOutputAsset(0)</outputAsset></taskBody>" \ }] \ }' return do_ams_post(endpoint, path, body, access_token)
python
{ "resource": "" }
q6556
helper_add
train
def helper_add(access_token, ck_id, path, body): '''Helper Function to add strings to a URL path. Args: access_token (str): A valid Azure authentication token. ck_id (str): A CK ID. path (str): A URL Path. body (str): A Body. Returns: HTTP response. JSON body. ''' full_path = ''.join([path, "('", ck_id, "')"]) full_path_encoded = urllib.parse.quote(full_path, safe='') endpoint = ''.join([ams_rest_endpoint, full_path_encoded]) return do_ams_put(endpoint, full_path_encoded, body, access_token, "json_only", "1.0;NetFx")
python
{ "resource": "" }
q6557
helper_list
train
def helper_list(access_token, oid, path): '''Helper Function to list a URL path. Args: access_token (str): A valid Azure authentication token. oid (str): An OID. path (str): A URL Path. Returns: HTTP response. JSON body. ''' if oid != "": path = ''.join([path, "('", oid, "')"]) endpoint = ''.join([ams_rest_endpoint, path]) return do_ams_get(endpoint, path, access_token)
python
{ "resource": "" }
q6558
helper_delete
train
def helper_delete(access_token, oid, path): '''Helper Function to delete a Object at a URL path. Args: access_token (str): A valid Azure authentication token. oid (str): An OID. path (str): A URL Path. Returns: HTTP response. JSON body. ''' full_path = ''.join([path, "('", oid, "')"]) full_path_encoded = urllib.parse.quote(full_path, safe='') endpoint = ''.join([ams_rest_endpoint, full_path_encoded]) return do_ams_delete(endpoint, full_path_encoded, access_token)
python
{ "resource": "" }
q6559
list_deployment_operations
train
def list_deployment_operations(access_token, subscription_id, rg_name, deployment_name): '''List all operations involved in a given deployment. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rg_name (str): Azure resource group name. Returns: HTTP response. JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourcegroups/', rg_name, '/providers/Microsoft.Resources/deployments/', deployment_name, '/operations', '?api-version=', BASE_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6560
create_lb_with_nat_pool
train
def create_lb_with_nat_pool(access_token, subscription_id, resource_group, lb_name, public_ip_id, fe_start_port, fe_end_port, backend_port, location): '''Create a load balancer with inbound NAT pools. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. lb_name (str): Name of the new load balancer. public_ip_id (str): Public IP address resource id. fe_start_port (int): Start of front-end port range. fe_end_port (int): End of front-end port range. backend_port (int): Back end port for VMs. location (str): Azure data center location. E.g. westus. Returns: HTTP response. Load Balancer JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/loadBalancers/', lb_name, '?api-version=', NETWORK_API]) lb_body = {'location': location} frontendipcconfig = {'name': 'LoadBalancerFrontEnd'} fipc_properties = {'publicIPAddress': {'id': public_ip_id}} frontendipcconfig['properties'] = fipc_properties properties = {'frontendIPConfigurations': [frontendipcconfig]} properties['backendAddressPools'] = [{'name': 'bepool'}] inbound_natpool = {'name': 'natpool'} lbfe_id = '/subscriptions/' + subscription_id + '/resourceGroups/' + resource_group + \ '/providers/Microsoft.Network/loadBalancers/' + lb_name + \ '/frontendIPConfigurations/LoadBalancerFrontEnd' ibnp_properties = {'frontendIPConfiguration': {'id': lbfe_id}} ibnp_properties['protocol'] = 'tcp' ibnp_properties['frontendPortRangeStart'] = fe_start_port ibnp_properties['frontendPortRangeEnd'] = fe_end_port ibnp_properties['backendPort'] = backend_port inbound_natpool['properties'] = ibnp_properties properties['inboundNatPools'] = [inbound_natpool] lb_body['properties'] = properties body = json.dumps(lb_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6561
create_nic
train
def create_nic(access_token, subscription_id, resource_group, nic_name, public_ip_id, subnet_id, location, nsg_id=None): '''Create a network interface with an associated public ip address. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. nic_name (str): Name of the new NIC. public_ip_id (str): Public IP address resource id. subnetid (str): Subnet resource id. location (str): Azure data center location. E.g. westus. nsg_id (str): Optional Network Secruity Group resource id. Returns: HTTP response. NIC JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkInterfaces/', nic_name, '?api-version=', NETWORK_API]) nic_body = {'location': location} ipconfig = {'name': 'ipconfig1'} ipc_properties = {'privateIPAllocationMethod': 'Dynamic'} ipc_properties['publicIPAddress'] = {'id': public_ip_id} ipc_properties['subnet'] = {'id': subnet_id} ipconfig['properties'] = ipc_properties properties = {'ipConfigurations': [ipconfig]} if nsg_id is not None: properties['networkSecurityGroup'] = {'id': nsg_id} nic_body['properties'] = properties body = json.dumps(nic_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6562
create_nsg_rule
train
def create_nsg_rule(access_token, subscription_id, resource_group, nsg_name, nsg_rule_name, description, protocol='Tcp', source_range='*', destination_range='*', source_prefix='*', destination_prefix='*', access='Allow', priority=100, direction='Inbound'): '''Create network security group rule. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. nsg_name (str): Name of the Network Security Group. nsg_rule_name (str): Name of the new rule. description (str): Description. protocol (str): Optional protocol. Default Tcp. source_range (str): Optional source IP range. Default '*'. destination_range (str): Destination IP range. Default *'. source_prefix (str): Source DNS prefix. Default '*'. destination_prefix (str): Destination prefix. Default '*'. access (str): Allow or deny rule. Default Allow. priority: Relative priority. Default 100. direction: Inbound or Outbound. Default Inbound. Returns: HTTP response. NSG JSON rule body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkSecurityGroups/', nsg_name, '/securityRules/', nsg_rule_name, '?api-version=', NETWORK_API]) properties = {'description': description} properties['protocol'] = protocol properties['sourcePortRange'] = source_range properties['destinationPortRange'] = destination_range properties['sourceAddressPrefix'] = source_prefix properties['destinationAddressPrefix'] = destination_prefix properties['access'] = access properties['priority'] = priority properties['direction'] = direction ip_body = {'properties': properties} body = json.dumps(ip_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6563
create_public_ip
train
def create_public_ip(access_token, subscription_id, resource_group, public_ip_name, dns_label, location): '''Create a public ip address. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. public_ip_name (str): Name of the new public ip address resource. dns_label (str): DNS label to apply to the IP address. location (str): Azure data center location. E.g. westus. Returns: HTTP response. Public IP address JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/publicIPAddresses/', public_ip_name, '?api-version=', NETWORK_API]) ip_body = {'location': location} properties = {'publicIPAllocationMethod': 'Dynamic'} properties['dnsSettings'] = {'domainNameLabel': dns_label} ip_body['properties'] = properties body = json.dumps(ip_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6564
create_vnet
train
def create_vnet(access_token, subscription_id, resource_group, name, location, address_prefix='10.0.0.0/16', subnet_prefix='10.0.0.0/16', nsg_id=None): '''Create a VNet with specified name and location. Optional subnet address prefix.. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. name (str): Name of the new VNet. location (str): Azure data center location. E.g. westus. address_prefix (str): Optional VNet address prefix. Default '10.0.0.0/16'. subnet_prefix (str): Optional subnet address prefix. Default '10.0.0.0/16'. nsg_id (str): Optional Netwrok Security Group resource Id. Default None. Returns: HTTP response. VNet JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/virtualNetworks/', name, '?api-version=', NETWORK_API]) vnet_body = {'location': location} properties = {'addressSpace': {'addressPrefixes': [address_prefix]}} subnet = {'name': 'subnet'} subnet['properties'] = {'addressPrefix': subnet_prefix} if nsg_id is not None: subnet['properties']['networkSecurityGroup'] = {'id': nsg_id} properties['subnets'] = [subnet] vnet_body['properties'] = properties body = json.dumps(vnet_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6565
delete_load_balancer
train
def delete_load_balancer(access_token, subscription_id, resource_group, lb_name): '''Delete a load balancer. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. lb_name (str): Name of the load balancer. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/loadBalancers/', lb_name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6566
delete_nsg
train
def delete_nsg(access_token, subscription_id, resource_group, nsg_name): '''Delete network security group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. nsg_name (str): Name of the NSG. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkSecurityGroups/', nsg_name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6567
delete_nsg_rule
train
def delete_nsg_rule(access_token, subscription_id, resource_group, nsg_name, nsg_rule_name): '''Delete network security group rule. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. nsg_name (str): Name of the Network Security Group. nsg_rule_name (str): Name of the NSG rule. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkSecurityGroups/', nsg_name, '/securityRules/', nsg_rule_name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6568
delete_public_ip
train
def delete_public_ip(access_token, subscription_id, resource_group, public_ip_name): '''Delete a public ip addresses associated with a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. public_ip_name (str): Name of the public ip address resource. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/publicIPAddresses/', public_ip_name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6569
delete_vnet
train
def delete_vnet(access_token, subscription_id, resource_group, name): '''Delete a virtual network. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. name (str): Name of the VNet. Returns: HTTP response. VNet JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/virtualNetworks/', name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6570
get_lb_nat_rule
train
def get_lb_nat_rule(access_token, subscription_id, resource_group, lb_name, rule_name): '''Get details about a load balancer inbound NAT rule. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. lb_name (str): Name of the load balancer. rule_name (str): Name of the NAT rule. Returns: HTTP response. JSON body of rule. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/loadBalancers/', lb_name, '/inboundNatRules/', rule_name, '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6571
get_network_usage
train
def get_network_usage(access_token, subscription_id, location): '''List network usage and limits for a location. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. location (str): Azure data center location. E.g. westus. Returns: HTTP response. JSON body of network usage. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/locations/', location, '/usages?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6572
get_nic
train
def get_nic(access_token, subscription_id, resource_group, nic_name): '''Get details about a network interface. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. nic_name (str): Name of the NIC. Returns: HTTP response. NIC JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkInterfaces/', nic_name, '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6573
get_public_ip
train
def get_public_ip(access_token, subscription_id, resource_group, ip_name): '''Get details about the named public ip address. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. public_ip_name (str): Name of the public ip address resource. Returns: HTTP response. Public IP address JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/', 'publicIPAddresses/', ip_name, '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6574
get_vnet
train
def get_vnet(access_token, subscription_id, resource_group, vnet_name): '''Get details about the named virtual network. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vnet_name (str): Name of the VNet. Returns: HTTP response. VNet JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/virtualNetworks/', vnet_name, '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6575
list_lb_nat_rules
train
def list_lb_nat_rules(access_token, subscription_id, resource_group, lb_name): '''List the inbound NAT rules for a load balancer. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. lb_name (str): Name of the load balancer. Returns: HTTP response. JSON body of load balancer NAT rules. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/loadBalancers/', lb_name, 'inboundNatRules?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6576
list_load_balancers
train
def list_load_balancers(access_token, subscription_id): '''List the load balancers in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of load balancer list with properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/', '/loadBalancers?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6577
list_nics
train
def list_nics(access_token, subscription_id): '''List the network interfaces in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of NICs list with properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/', '/networkInterfaces?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6578
list_vnets
train
def list_vnets(access_token, subscription_id): '''List the VNETs in a subscription . Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of VNets list with properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/', '/virtualNetworks?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6579
update_load_balancer
train
def update_load_balancer(access_token, subscription_id, resource_group, lb_name, body): '''Updates a load balancer model, i.e. PUT an updated LB body. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. lb_name (str): Name of the new load balancer. body (str): JSON body of an updated load balancer. Returns: HTTP response. Load Balancer JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/loadBalancers/', lb_name, '?api-version=', NETWORK_API]) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6580
print_region_quota
train
def print_region_quota(access_token, sub_id, region): '''Print the Compute usage quota for a specific region''' print(region + ':') quota = azurerm.get_compute_usage(access_token, sub_id, region) if SUMMARY is False: print(json.dumps(quota, sort_keys=False, indent=2, separators=(',', ': '))) try: for resource in quota['value']: if resource['name']['value'] == 'cores': print(' Current: ' + str(resource['currentValue']) + ', limit: ' + str(resource['limit'])) break except KeyError: print('Invalid data for region: ' + region)
python
{ "resource": "" }
q6581
create_as
train
def create_as(access_token, subscription_id, resource_group, as_name, update_domains, fault_domains, location): '''Create availability set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. as_name (str): Name of the new availability set. update_domains (int): Number of update domains. fault_domains (int): Number of fault domains. location (str): Azure data center location. E.g. westus. Returns: HTTP response. JSON body of the availability set properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/availabilitySets/', as_name, '?api-version=', COMP_API]) as_body = {'location': location} properties = {'platformUpdateDomainCount': update_domains} properties['platformFaultDomainCount'] = fault_domains as_body['properties'] = properties body = json.dumps(as_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6582
create_vm
train
def create_vm(access_token, subscription_id, resource_group, vm_name, vm_size, publisher, offer, sku, version, nic_id, location, storage_type='Standard_LRS', osdisk_name=None, username='azure', password=None, public_key=None): '''Create a new Azure virtual machine. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vm_name (str): Name of the new virtual machine. vm_size (str): Size of virtual machine, e.g. 'Standard_D1_v2'. publisher (str): VM image publisher. E.g. 'MicrosoftWindowsServer'. offer (str): VM image offer. E.g. 'WindowsServer'. sku (str): VM image sku. E.g. '2016-Datacenter'. version (str): VM image version. E.g. 'latest'. nic_id (str): Resource id of a NIC. location (str): Azure data center location. E.g. westus. storage_type (str): Optional storage type. Default 'Standard_LRS'. osdisk_name (str): Optional OS disk name. Default is None. username (str): Optional user name. Default is 'azure'. password (str): Optional password. Default is None (not required if using public_key). public_key (str): Optional public key. Default is None (not required if using password, e.g. on Windows). Returns: HTTP response. JSON body of the virtual machine properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachines/', vm_name, '?api-version=', COMP_API]) if osdisk_name is None: osdisk_name = vm_name + 'osdisk' vm_body = {'name': vm_name} vm_body['location'] = location properties = {'hardwareProfile': {'vmSize': vm_size}} image_reference = {'publisher': publisher, 'offer': offer, 'sku': sku, 'version': version} storage_profile = {'imageReference': image_reference} os_disk = {'name': osdisk_name} os_disk['managedDisk'] = {'storageAccountType': storage_type} os_disk['caching'] = 'ReadWrite' os_disk['createOption'] = 'fromImage' storage_profile['osDisk'] = os_disk properties['storageProfile'] = storage_profile os_profile = {'computerName': vm_name} os_profile['adminUsername'] = username if password is not None: os_profile['adminPassword'] = password if public_key is not None: if password is None: disable_pswd = True else: disable_pswd = False linux_config = {'disablePasswordAuthentication': disable_pswd} pub_key = {'path': '/home/' + username + '/.ssh/authorized_keys'} pub_key['keyData'] = public_key linux_config['ssh'] = {'publicKeys': [pub_key]} os_profile['linuxConfiguration'] = linux_config properties['osProfile'] = os_profile network_profile = {'networkInterfaces': [ {'id': nic_id, 'properties': {'primary': True}}]} properties['networkProfile'] = network_profile vm_body['properties'] = properties body = json.dumps(vm_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6583
create_vmss
train
def create_vmss(access_token, subscription_id, resource_group, vmss_name, vm_size, capacity, publisher, offer, sku, version, subnet_id, location, be_pool_id=None, lb_pool_id=None, storage_type='Standard_LRS', username='azure', password=None, public_key=None, overprovision=True, upgrade_policy='Manual', public_ip_per_vm=False): '''Create virtual machine scale set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the new scale set. vm_size (str): Size of virtual machine, e.g. 'Standard_D1_v2'. capacity (int): Number of VMs in the scale set. 0-1000. publisher (str): VM image publisher. E.g. 'MicrosoftWindowsServer'. offer (str): VM image offer. E.g. 'WindowsServer'. sku (str): VM image sku. E.g. '2016-Datacenter'. version (str): VM image version. E.g. 'latest'. subnet_id (str): Resource id of a subnet. location (str): Azure data center location. E.g. westus. be_pool_id (str): Resource id of a backend NAT pool. lb_pool_id (str): Resource id of a load balancer pool. storage_type (str): Optional storage type. Default 'Standard_LRS'. username (str): Optional user name. Default is 'azure'. password (str): Optional password. Default is None (not required if using public_key). public_key (str): Optional public key. Default is None (not required if using password, e.g. on Windows). overprovision (bool): Optional. Enable overprovisioning of VMs. Default True. upgrade_policy (str): Optional. Set upgrade policy to Automatic, Manual or Rolling. Default 'Manual'. public_ip_per_vm (bool): Optional. Set public IP per VM. Default False. Returns: HTTP response. JSON body of the virtual machine scale set properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets/', vmss_name, '?api-version=', COMP_API]) vmss_body = {'location': location} vmss_sku = {'name': vm_size, 'tier': 'Standard', 'capacity': capacity} vmss_body['sku'] = vmss_sku properties = {'overprovision': overprovision} properties['upgradePolicy'] = {'mode': upgrade_policy} os_profile = {'computerNamePrefix': vmss_name} os_profile['adminUsername'] = username if password is not None: os_profile['adminPassword'] = password if public_key is not None: if password is None: disable_pswd = True else: disable_pswd = False linux_config = {'disablePasswordAuthentication': disable_pswd} pub_key = {'path': '/home/' + username + '/.ssh/authorized_keys'} pub_key['keyData'] = public_key linux_config['ssh'] = {'publicKeys': [pub_key]} os_profile['linuxConfiguration'] = linux_config vm_profile = {'osProfile': os_profile} os_disk = {'createOption': 'fromImage'} os_disk['managedDisk'] = {'storageAccountType': storage_type} os_disk['caching'] = 'ReadWrite' storage_profile = {'osDisk': os_disk} storage_profile['imageReference'] = \ {'publisher': publisher, 'offer': offer, 'sku': sku, 'version': version} vm_profile['storageProfile'] = storage_profile nic = {'name': vmss_name} ip_config = {'name': vmss_name} ip_properties = {'subnet': {'id': subnet_id}} if be_pool_id is not None: ip_properties['loadBalancerBackendAddressPools'] = [{'id': be_pool_id}] if lb_pool_id is not None: ip_properties['loadBalancerInboundNatPools'] = [{'id': lb_pool_id}] if public_ip_per_vm is True: ip_properties['publicIpAddressConfiguration'] = { 'name': 'pubip', 'properties': {'idleTimeoutInMinutes': 15}} ip_config['properties'] = ip_properties nic['properties'] = {'primary': True, 'ipConfigurations': [ip_config]} network_profile = {'networkInterfaceConfigurations': [nic]} vm_profile['networkProfile'] = network_profile properties['virtualMachineProfile'] = vm_profile vmss_body['properties'] = properties body = json.dumps(vmss_body) return do_put(endpoint, body, access_token)
python
{ "resource": "" }
q6584
delete_as
train
def delete_as(access_token, subscription_id, resource_group, as_name): '''Delete availability set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. as_name (str): Name of the availability set. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/availabilitySets/', as_name, '?api-version=', COMP_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6585
delete_vmss
train
def delete_vmss(access_token, subscription_id, resource_group, vmss_name): '''Delete a virtual machine scale set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the virtual machine scale set. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets/', vmss_name, '?api-version=', COMP_API]) return do_delete(endpoint, access_token)
python
{ "resource": "" }
q6586
delete_vmss_vms
train
def delete_vmss_vms(access_token, subscription_id, resource_group, vmss_name, vm_ids): '''Delete a VM in a VM Scale Set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the virtual machine scale set. vm_ids (str): String representation of a JSON list of VM IDs. E.g. '[1,2]'. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets/', vmss_name, '/delete?api-version=', COMP_API]) body = '{"instanceIds" : ' + vm_ids + '}' return do_post(endpoint, body, access_token)
python
{ "resource": "" }
q6587
get_compute_usage
train
def get_compute_usage(access_token, subscription_id, location): '''List compute usage and limits for a location. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. location (str): Azure data center location. E.g. westus. Returns: HTTP response. JSON body of Compute usage and limits data. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.compute/locations/', location, '/usages?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6588
get_vm
train
def get_vm(access_token, subscription_id, resource_group, vm_name): '''Get virtual machine details. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vm_name (str): Name of the virtual machine. Returns: HTTP response. JSON body of VM properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachines/', vm_name, '?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6589
get_vm_extension
train
def get_vm_extension(access_token, subscription_id, resource_group, vm_name, extension_name): '''Get details about a VM extension. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vm_name (str): Name of the virtual machine. extension_name (str): VM extension name. Returns: HTTP response. JSON body of VM extension properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachines/', vm_name, '/extensions/', extension_name, '?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6590
get_vmss
train
def get_vmss(access_token, subscription_id, resource_group, vmss_name): '''Get virtual machine scale set details. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the virtual machine scale set. Returns: HTTP response. JSON body of scale set properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets/', vmss_name, '?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6591
get_vmss_vm
train
def get_vmss_vm(access_token, subscription_id, resource_group, vmss_name, instance_id): '''Get individual VMSS VM details. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the virtual machine scale set. instance_id (int): VM ID of the scale set VM. Returns: HTTP response. JSON body of VMSS VM model view. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets/', vmss_name, '/virtualMachines/', str(instance_id), '?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6592
get_as
train
def get_as(access_token, subscription_id, resource_group, as_name): '''Get availability set details. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. as_name (str): Name of the new availability set. Returns: HTTP response. JSON body of the availability set properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/availabilitySets/', as_name, '?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6593
list_as_sub
train
def list_as_sub(access_token, subscription_id): '''List availability sets in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of the list of availability set properties. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Compute/availabilitySets', '?api-version=', COMP_API]) return do_get_next(endpoint, access_token)
python
{ "resource": "" }
q6594
list_vm_images_sub
train
def list_vm_images_sub(access_token, subscription_id): '''List VM images in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of a list of VM images. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Compute/images', '?api-version=', COMP_API]) return do_get_next(endpoint, access_token)
python
{ "resource": "" }
q6595
list_vms
train
def list_vms(access_token, subscription_id, resource_group): '''List VMs in a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. Returns: HTTP response. JSON body of a list of VM model views. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachines', '?api-version=', COMP_API]) return do_get(endpoint, access_token)
python
{ "resource": "" }
q6596
list_vms_sub
train
def list_vms_sub(access_token, subscription_id): '''List VMs in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of a list of VM model views. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Compute/virtualMachines', '?api-version=', COMP_API]) return do_get_next(endpoint, access_token)
python
{ "resource": "" }
q6597
list_vmss
train
def list_vmss(access_token, subscription_id, resource_group): '''List VM Scale Sets in a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. Returns: HTTP response. JSON body of a list of scale set model views. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets', '?api-version=', COMP_API]) return do_get_next(endpoint, access_token)
python
{ "resource": "" }
q6598
list_vmss_skus
train
def list_vmss_skus(access_token, subscription_id, resource_group, vmss_name): '''List the VM skus available for a VM Scale Set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the virtual machine scale set. Returns: HTTP response. JSON body of VM skus. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachineScaleSets/', vmss_name, '/skus', '?api-version=', COMP_API]) return do_get_next(endpoint, access_token)
python
{ "resource": "" }
q6599
list_vmss_sub
train
def list_vmss_sub(access_token, subscription_id): '''List VM Scale Sets in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of VM scale sets. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Compute/virtualMachineScaleSets', '?api-version=', COMP_API]) return do_get_next(endpoint, access_token)
python
{ "resource": "" }