_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
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(),
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,
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,
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
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:
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_
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
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
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:
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 = []
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)):
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'''
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(
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 = {}
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.
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.
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.
python
{ "resource": "" }
q6517
handle_bad_update
train
def handle_bad_update(operation, ret): '''report error for bad update''' print("Error " + operation)
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
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']:
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,
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,
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,
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,
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(),
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(),
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,
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
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,
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.
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.
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(),
python
{ "resource": "" }
q6532
rgfromid
train
def rgfromid(idstr): '''get resource group name from the id string''' rgidx = idstr.find('resourceGroups/') 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,
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. '''
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,
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,
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(),
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(),
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
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.
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 = '{ \
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'
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",
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. '''
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
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":"'
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
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, \
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'
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'
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 =
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:
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.
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'
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", "('",
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. '''
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.
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,
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,
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'}
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 =
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,
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(),
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,
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,
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,
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,
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,
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,
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(),
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.
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,
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,
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,
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,
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(),
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(),
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(),
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(),
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']
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.
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,
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
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,
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,
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(),
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.
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,
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/',
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,
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(),
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
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(),
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(),
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,
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(),
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,
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,
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(),
python
{ "resource": "" }