repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
gbowerman/azurerm
examples/vip_swap.py
main
def main(): '''main routine''' # create parser arg_parser = argparse.ArgumentParser() # arguments: resource group lb name 1, 2 arg_parser.add_argument('--resourcegroup', '-g', required=True, dest='resource_group', action='store', help='Resource group name') arg_parser.add_argument('--lb1', '-1', required=True, action='store', help='Load balancer 1 name') arg_parser.add_argument('--lb2', '-2', required=True, action='store', help='Load balancer 2 name') arg_parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Show additional information') arg_parser.add_argument('-y', dest='noprompt', action='store_true', default=False, help='Do not prompt for confirmation') args = arg_parser.parse_args() verbose = args.verbose # print extra status information when True resource_group = args.resource_group lb1 = args.lb1 lb2 = args.lb2 # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: print("Error: Expecting lbconfig.json in current folder") sys.exit() tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # figure out location of resource group and use that for the float ip rgroup = azurerm.get_resource_group( access_token, subscription_id, resource_group) location = rgroup['location'] # Create a spare public IP address ip_name = Haikunator().haikunate(delimiter='') dns_label = ip_name + 'dns' print('Creating float public IP: ' + ip_name) ip_ret = azurerm.create_public_ip( access_token, subscription_id, resource_group, ip_name, dns_label, location) floatip_id = ip_ret.json()['id'] if verbose is True: print('Float ip id = ' + floatip_id) # 1. Get lb 2 lbmodel2 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb2) lb2_ip_id = \ lbmodel2['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id'] lb2_ip_name = lb2_ip_id.split('publicIPAddresses/', 1)[1] if verbose is True: print(lb2 + ' ip id: ' + lb2_ip_id) print(lb2 + ' model:') print(json.dumps(lbmodel2, sort_keys=False, indent=2, separators=(',', ': '))) # 2. Assign new ip to lb 2 print('Updating ' + lb2 + ' ip to float ip: ' + ip_name) lbmodel2['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id']\ = floatip_id ret = azurerm.update_load_balancer(access_token, subscription_id, resource_group, lb2, json.dumps(lbmodel2)) if ret.status_code != 200: handle_bad_update("updating " + lb2, ret) if verbose is True: print('original ip id: ' + lb2_ip_id + ', new ip id: ' + floatip_id) print(json.dumps(ret, sort_keys=False, indent=2, separators=(',', ': '))) print('Waiting for old ' + lb2 + ' ip: ' + lb2_ip_name + ' to be unnassigned') waiting = True start1 = time.time() while waiting: lbmodel2 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb2) if lbmodel2['properties']['provisioningState'] == 'Succeeded': waiting = False time.sleep(3) end1 = time.time() print('Elapsed time: ' + str(int(end1 - start1))) # 3. Get lb 1 lbmodel1 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb1) lb1_ip_id = \ lbmodel1['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id'] if verbose is True: print(lb1 + ' ip id: ' + lb1_ip_id) print(lb1 + ' model:') print(json.dumps(lbmodel1, sort_keys=False, indent=2, separators=(',', ': '))) lb1_ip_name = lb1_ip_id.split('publicIPAddresses/', 1)[1] # 4. Assign old ip 2 to lb 1 print('Downtime begins: Updating ' + lb1 + ' ip to ' + lb2_ip_name) start2 = time.time() lbmodel1['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id'] \ = lb2_ip_id ret = azurerm.update_load_balancer(access_token, subscription_id, resource_group, lb1, json.dumps(lbmodel1)) if ret.status_code != 200: handle_bad_update("updating " + lb1, ret) if verbose is True: print(json.dumps(ret, sort_keys=False, indent=2, separators=(',', ': '))) print('Waiting for old ' + lb1 + ' ip: ' + lb1_ip_name + ' to be unnassigned') waiting = True while waiting: lbmodel1 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb1) if lbmodel1['properties']['provisioningState'] == 'Succeeded': waiting = False time.sleep(3) end2 = time.time() print('Staging IP ' + lb2_ip_name + ' now points to old production LB ' + lb1) print('Elapsed time: ' + str(int(end2 - start1))) # 5. Assign old ip 1 to lb 2 print('Updating ' + lb2 + ' ip to ' + lb1_ip_name) lbmodel2['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id']\ = lb1_ip_id ret = azurerm.update_load_balancer(access_token, subscription_id, resource_group, lb2, json.dumps(lbmodel2)) if ret.status_code != 200: handle_bad_update('updating ' + lb2, ret) if verbose is True: print('Original ip id: ' + lb2_ip_id + ', new ip id: ' + lb1_ip_id) print(json.dumps(ret, sort_keys=False, indent=2, separators=(',', ': '))) print('Waiting for ' + lb2 + ' provisioning to complete') waiting = True while waiting: lbmodel2 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb2) if lbmodel2['properties']['provisioningState'] == 'Succeeded': waiting = False time.sleep(3) end3 = time.time() # 6. Delete floatip print('VIP swap complete') print('Downtime: ' + str(int(end3 - start2)) + '. Total elapsed time: ' + str(int(end3 - start1))) print('Deleting float ip: ' + ip_name) azurerm.delete_public_ip(access_token, subscription_id, resource_group, ip_name)
python
def main(): '''main routine''' # create parser arg_parser = argparse.ArgumentParser() # arguments: resource group lb name 1, 2 arg_parser.add_argument('--resourcegroup', '-g', required=True, dest='resource_group', action='store', help='Resource group name') arg_parser.add_argument('--lb1', '-1', required=True, action='store', help='Load balancer 1 name') arg_parser.add_argument('--lb2', '-2', required=True, action='store', help='Load balancer 2 name') arg_parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Show additional information') arg_parser.add_argument('-y', dest='noprompt', action='store_true', default=False, help='Do not prompt for confirmation') args = arg_parser.parse_args() verbose = args.verbose # print extra status information when True resource_group = args.resource_group lb1 = args.lb1 lb2 = args.lb2 # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: print("Error: Expecting lbconfig.json in current folder") sys.exit() tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # figure out location of resource group and use that for the float ip rgroup = azurerm.get_resource_group( access_token, subscription_id, resource_group) location = rgroup['location'] # Create a spare public IP address ip_name = Haikunator().haikunate(delimiter='') dns_label = ip_name + 'dns' print('Creating float public IP: ' + ip_name) ip_ret = azurerm.create_public_ip( access_token, subscription_id, resource_group, ip_name, dns_label, location) floatip_id = ip_ret.json()['id'] if verbose is True: print('Float ip id = ' + floatip_id) # 1. Get lb 2 lbmodel2 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb2) lb2_ip_id = \ lbmodel2['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id'] lb2_ip_name = lb2_ip_id.split('publicIPAddresses/', 1)[1] if verbose is True: print(lb2 + ' ip id: ' + lb2_ip_id) print(lb2 + ' model:') print(json.dumps(lbmodel2, sort_keys=False, indent=2, separators=(',', ': '))) # 2. Assign new ip to lb 2 print('Updating ' + lb2 + ' ip to float ip: ' + ip_name) lbmodel2['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id']\ = floatip_id ret = azurerm.update_load_balancer(access_token, subscription_id, resource_group, lb2, json.dumps(lbmodel2)) if ret.status_code != 200: handle_bad_update("updating " + lb2, ret) if verbose is True: print('original ip id: ' + lb2_ip_id + ', new ip id: ' + floatip_id) print(json.dumps(ret, sort_keys=False, indent=2, separators=(',', ': '))) print('Waiting for old ' + lb2 + ' ip: ' + lb2_ip_name + ' to be unnassigned') waiting = True start1 = time.time() while waiting: lbmodel2 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb2) if lbmodel2['properties']['provisioningState'] == 'Succeeded': waiting = False time.sleep(3) end1 = time.time() print('Elapsed time: ' + str(int(end1 - start1))) # 3. Get lb 1 lbmodel1 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb1) lb1_ip_id = \ lbmodel1['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id'] if verbose is True: print(lb1 + ' ip id: ' + lb1_ip_id) print(lb1 + ' model:') print(json.dumps(lbmodel1, sort_keys=False, indent=2, separators=(',', ': '))) lb1_ip_name = lb1_ip_id.split('publicIPAddresses/', 1)[1] # 4. Assign old ip 2 to lb 1 print('Downtime begins: Updating ' + lb1 + ' ip to ' + lb2_ip_name) start2 = time.time() lbmodel1['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id'] \ = lb2_ip_id ret = azurerm.update_load_balancer(access_token, subscription_id, resource_group, lb1, json.dumps(lbmodel1)) if ret.status_code != 200: handle_bad_update("updating " + lb1, ret) if verbose is True: print(json.dumps(ret, sort_keys=False, indent=2, separators=(',', ': '))) print('Waiting for old ' + lb1 + ' ip: ' + lb1_ip_name + ' to be unnassigned') waiting = True while waiting: lbmodel1 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb1) if lbmodel1['properties']['provisioningState'] == 'Succeeded': waiting = False time.sleep(3) end2 = time.time() print('Staging IP ' + lb2_ip_name + ' now points to old production LB ' + lb1) print('Elapsed time: ' + str(int(end2 - start1))) # 5. Assign old ip 1 to lb 2 print('Updating ' + lb2 + ' ip to ' + lb1_ip_name) lbmodel2['properties']['frontendIPConfigurations'][0]['properties']['publicIPAddress']['id']\ = lb1_ip_id ret = azurerm.update_load_balancer(access_token, subscription_id, resource_group, lb2, json.dumps(lbmodel2)) if ret.status_code != 200: handle_bad_update('updating ' + lb2, ret) if verbose is True: print('Original ip id: ' + lb2_ip_id + ', new ip id: ' + lb1_ip_id) print(json.dumps(ret, sort_keys=False, indent=2, separators=(',', ': '))) print('Waiting for ' + lb2 + ' provisioning to complete') waiting = True while waiting: lbmodel2 = azurerm.get_load_balancer( access_token, subscription_id, resource_group, lb2) if lbmodel2['properties']['provisioningState'] == 'Succeeded': waiting = False time.sleep(3) end3 = time.time() # 6. Delete floatip print('VIP swap complete') print('Downtime: ' + str(int(end3 - start2)) + '. Total elapsed time: ' + str(int(end3 - start1))) print('Deleting float ip: ' + ip_name) azurerm.delete_public_ip(access_token, subscription_id, resource_group, ip_name)
[ "def", "main", "(", ")", ":", "# create parser", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# arguments: resource group lb name 1, 2", "arg_parser", ".", "add_argument", "(", "'--resourcegroup'", ",", "'-g'", ",", "required", "=", "True", ",", "dest", "=", "'resource_group'", ",", "action", "=", "'store'", ",", "help", "=", "'Resource group name'", ")", "arg_parser", ".", "add_argument", "(", "'--lb1'", ",", "'-1'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Load balancer 1 name'", ")", "arg_parser", ".", "add_argument", "(", "'--lb2'", ",", "'-2'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Load balancer 2 name'", ")", "arg_parser", ".", "add_argument", "(", "'--verbose'", ",", "'-v'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "'Show additional information'", ")", "arg_parser", ".", "add_argument", "(", "'-y'", ",", "dest", "=", "'noprompt'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "'Do not prompt for confirmation'", ")", "args", "=", "arg_parser", ".", "parse_args", "(", ")", "verbose", "=", "args", ".", "verbose", "# print extra status information when True", "resource_group", "=", "args", ".", "resource_group", "lb1", "=", "args", ".", "lb1", "lb2", "=", "args", ".", "lb2", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "print", "(", "\"Error: Expecting lbconfig.json in current folder\"", ")", "sys", ".", "exit", "(", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# figure out location of resource group and use that for the float ip", "rgroup", "=", "azurerm", ".", "get_resource_group", "(", "access_token", ",", "subscription_id", ",", "resource_group", ")", "location", "=", "rgroup", "[", "'location'", "]", "# Create a spare public IP address", "ip_name", "=", "Haikunator", "(", ")", ".", "haikunate", "(", "delimiter", "=", "''", ")", "dns_label", "=", "ip_name", "+", "'dns'", "print", "(", "'Creating float public IP: '", "+", "ip_name", ")", "ip_ret", "=", "azurerm", ".", "create_public_ip", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "ip_name", ",", "dns_label", ",", "location", ")", "floatip_id", "=", "ip_ret", ".", "json", "(", ")", "[", "'id'", "]", "if", "verbose", "is", "True", ":", "print", "(", "'Float ip id = '", "+", "floatip_id", ")", "# 1. Get lb 2", "lbmodel2", "=", "azurerm", ".", "get_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb2", ")", "lb2_ip_id", "=", "lbmodel2", "[", "'properties'", "]", "[", "'frontendIPConfigurations'", "]", "[", "0", "]", "[", "'properties'", "]", "[", "'publicIPAddress'", "]", "[", "'id'", "]", "lb2_ip_name", "=", "lb2_ip_id", ".", "split", "(", "'publicIPAddresses/'", ",", "1", ")", "[", "1", "]", "if", "verbose", "is", "True", ":", "print", "(", "lb2", "+", "' ip id: '", "+", "lb2_ip_id", ")", "print", "(", "lb2", "+", "' model:'", ")", "print", "(", "json", ".", "dumps", "(", "lbmodel2", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")", "# 2. Assign new ip to lb 2", "print", "(", "'Updating '", "+", "lb2", "+", "' ip to float ip: '", "+", "ip_name", ")", "lbmodel2", "[", "'properties'", "]", "[", "'frontendIPConfigurations'", "]", "[", "0", "]", "[", "'properties'", "]", "[", "'publicIPAddress'", "]", "[", "'id'", "]", "=", "floatip_id", "ret", "=", "azurerm", ".", "update_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb2", ",", "json", ".", "dumps", "(", "lbmodel2", ")", ")", "if", "ret", ".", "status_code", "!=", "200", ":", "handle_bad_update", "(", "\"updating \"", "+", "lb2", ",", "ret", ")", "if", "verbose", "is", "True", ":", "print", "(", "'original ip id: '", "+", "lb2_ip_id", "+", "', new ip id: '", "+", "floatip_id", ")", "print", "(", "json", ".", "dumps", "(", "ret", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")", "print", "(", "'Waiting for old '", "+", "lb2", "+", "' ip: '", "+", "lb2_ip_name", "+", "' to be unnassigned'", ")", "waiting", "=", "True", "start1", "=", "time", ".", "time", "(", ")", "while", "waiting", ":", "lbmodel2", "=", "azurerm", ".", "get_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb2", ")", "if", "lbmodel2", "[", "'properties'", "]", "[", "'provisioningState'", "]", "==", "'Succeeded'", ":", "waiting", "=", "False", "time", ".", "sleep", "(", "3", ")", "end1", "=", "time", ".", "time", "(", ")", "print", "(", "'Elapsed time: '", "+", "str", "(", "int", "(", "end1", "-", "start1", ")", ")", ")", "# 3. Get lb 1", "lbmodel1", "=", "azurerm", ".", "get_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb1", ")", "lb1_ip_id", "=", "lbmodel1", "[", "'properties'", "]", "[", "'frontendIPConfigurations'", "]", "[", "0", "]", "[", "'properties'", "]", "[", "'publicIPAddress'", "]", "[", "'id'", "]", "if", "verbose", "is", "True", ":", "print", "(", "lb1", "+", "' ip id: '", "+", "lb1_ip_id", ")", "print", "(", "lb1", "+", "' model:'", ")", "print", "(", "json", ".", "dumps", "(", "lbmodel1", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")", "lb1_ip_name", "=", "lb1_ip_id", ".", "split", "(", "'publicIPAddresses/'", ",", "1", ")", "[", "1", "]", "# 4. Assign old ip 2 to lb 1", "print", "(", "'Downtime begins: Updating '", "+", "lb1", "+", "' ip to '", "+", "lb2_ip_name", ")", "start2", "=", "time", ".", "time", "(", ")", "lbmodel1", "[", "'properties'", "]", "[", "'frontendIPConfigurations'", "]", "[", "0", "]", "[", "'properties'", "]", "[", "'publicIPAddress'", "]", "[", "'id'", "]", "=", "lb2_ip_id", "ret", "=", "azurerm", ".", "update_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb1", ",", "json", ".", "dumps", "(", "lbmodel1", ")", ")", "if", "ret", ".", "status_code", "!=", "200", ":", "handle_bad_update", "(", "\"updating \"", "+", "lb1", ",", "ret", ")", "if", "verbose", "is", "True", ":", "print", "(", "json", ".", "dumps", "(", "ret", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")", "print", "(", "'Waiting for old '", "+", "lb1", "+", "' ip: '", "+", "lb1_ip_name", "+", "' to be unnassigned'", ")", "waiting", "=", "True", "while", "waiting", ":", "lbmodel1", "=", "azurerm", ".", "get_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb1", ")", "if", "lbmodel1", "[", "'properties'", "]", "[", "'provisioningState'", "]", "==", "'Succeeded'", ":", "waiting", "=", "False", "time", ".", "sleep", "(", "3", ")", "end2", "=", "time", ".", "time", "(", ")", "print", "(", "'Staging IP '", "+", "lb2_ip_name", "+", "' now points to old production LB '", "+", "lb1", ")", "print", "(", "'Elapsed time: '", "+", "str", "(", "int", "(", "end2", "-", "start1", ")", ")", ")", "# 5. Assign old ip 1 to lb 2", "print", "(", "'Updating '", "+", "lb2", "+", "' ip to '", "+", "lb1_ip_name", ")", "lbmodel2", "[", "'properties'", "]", "[", "'frontendIPConfigurations'", "]", "[", "0", "]", "[", "'properties'", "]", "[", "'publicIPAddress'", "]", "[", "'id'", "]", "=", "lb1_ip_id", "ret", "=", "azurerm", ".", "update_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb2", ",", "json", ".", "dumps", "(", "lbmodel2", ")", ")", "if", "ret", ".", "status_code", "!=", "200", ":", "handle_bad_update", "(", "'updating '", "+", "lb2", ",", "ret", ")", "if", "verbose", "is", "True", ":", "print", "(", "'Original ip id: '", "+", "lb2_ip_id", "+", "', new ip id: '", "+", "lb1_ip_id", ")", "print", "(", "json", ".", "dumps", "(", "ret", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")", "print", "(", "'Waiting for '", "+", "lb2", "+", "' provisioning to complete'", ")", "waiting", "=", "True", "while", "waiting", ":", "lbmodel2", "=", "azurerm", ".", "get_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb2", ")", "if", "lbmodel2", "[", "'properties'", "]", "[", "'provisioningState'", "]", "==", "'Succeeded'", ":", "waiting", "=", "False", "time", ".", "sleep", "(", "3", ")", "end3", "=", "time", ".", "time", "(", ")", "# 6. Delete floatip", "print", "(", "'VIP swap complete'", ")", "print", "(", "'Downtime: '", "+", "str", "(", "int", "(", "end3", "-", "start2", ")", ")", "+", "'. Total elapsed time: '", "+", "str", "(", "int", "(", "end3", "-", "start1", ")", ")", ")", "print", "(", "'Deleting float ip: '", "+", "ip_name", ")", "azurerm", ".", "delete_public_ip", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "ip_name", ")" ]
main routine
[ "main", "routine" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/vip_swap.py#L18-L176
gbowerman/azurerm
docs/py2md.py
extract_code
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
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}
[ "def", "extract_code", "(", "end_mark", ",", "current_str", ",", "str_array", ",", "line_num", ")", ":", "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", "}" ]
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.
[ "Extract", "a", "multi", "-", "line", "string", "from", "a", "string", "array", "up", "to", "a", "specified", "end", "marker", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/docs/py2md.py#L7-L30
gbowerman/azurerm
docs/py2md.py
process_file
def process_file(pyfile_name): '''Process a Python source file with Google style docstring comments. Reads file header comment, function definitions, function docstrings. Returns dictionary encapsulation for subsequent writing. Args: pyfile_name (str): file name to read. Returns: Dictionary object containing summary comment, with a list of entries for each function. ''' print('Processing file: ' + pyfile_name) # load the source file with open(pyfile_name) as fpyfile: pyfile_str = fpyfile.readlines() # meta-doc for a source file file_dict = {'source_file': pyfile_name.replace('\\', '/')} # get file summary line at the top of the file if pyfile_str[0].startswith("'''"): file_dict['summary_comment'] = pyfile_str[0][:-1].strip("'") else: file_dict['summary_comment'] = pyfile_name file_dict['functions'] = [] # find every function definition for line in pyfile_str: # process definition if line.startswith('def '): line_num = pyfile_str.index(line) fn_def = line[4:] fn_name = fn_def.split('(')[0] function_info = {'name': fn_name} extract = extract_code(':', fn_def, pyfile_str, line_num) function_info['definition'] = extract['current_str'] # process docstring line_num = extract['line_num'] + 1 doc_line = pyfile_str[line_num] if doc_line.startswith(" '''"): comment_str = doc_line[7:] extract = extract_code( "'''", comment_str, pyfile_str, line_num) function_info['comments'] = extract['current_str'] file_dict['functions'].append(function_info) return file_dict
python
def process_file(pyfile_name): '''Process a Python source file with Google style docstring comments. Reads file header comment, function definitions, function docstrings. Returns dictionary encapsulation for subsequent writing. Args: pyfile_name (str): file name to read. Returns: Dictionary object containing summary comment, with a list of entries for each function. ''' print('Processing file: ' + pyfile_name) # load the source file with open(pyfile_name) as fpyfile: pyfile_str = fpyfile.readlines() # meta-doc for a source file file_dict = {'source_file': pyfile_name.replace('\\', '/')} # get file summary line at the top of the file if pyfile_str[0].startswith("'''"): file_dict['summary_comment'] = pyfile_str[0][:-1].strip("'") else: file_dict['summary_comment'] = pyfile_name file_dict['functions'] = [] # find every function definition for line in pyfile_str: # process definition if line.startswith('def '): line_num = pyfile_str.index(line) fn_def = line[4:] fn_name = fn_def.split('(')[0] function_info = {'name': fn_name} extract = extract_code(':', fn_def, pyfile_str, line_num) function_info['definition'] = extract['current_str'] # process docstring line_num = extract['line_num'] + 1 doc_line = pyfile_str[line_num] if doc_line.startswith(" '''"): comment_str = doc_line[7:] extract = extract_code( "'''", comment_str, pyfile_str, line_num) function_info['comments'] = extract['current_str'] file_dict['functions'].append(function_info) return file_dict
[ "def", "process_file", "(", "pyfile_name", ")", ":", "print", "(", "'Processing file: '", "+", "pyfile_name", ")", "# load the source file", "with", "open", "(", "pyfile_name", ")", "as", "fpyfile", ":", "pyfile_str", "=", "fpyfile", ".", "readlines", "(", ")", "# meta-doc for a source file", "file_dict", "=", "{", "'source_file'", ":", "pyfile_name", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "}", "# get file summary line at the top of the file", "if", "pyfile_str", "[", "0", "]", ".", "startswith", "(", "\"'''\"", ")", ":", "file_dict", "[", "'summary_comment'", "]", "=", "pyfile_str", "[", "0", "]", "[", ":", "-", "1", "]", ".", "strip", "(", "\"'\"", ")", "else", ":", "file_dict", "[", "'summary_comment'", "]", "=", "pyfile_name", "file_dict", "[", "'functions'", "]", "=", "[", "]", "# find every function definition", "for", "line", "in", "pyfile_str", ":", "# process definition", "if", "line", ".", "startswith", "(", "'def '", ")", ":", "line_num", "=", "pyfile_str", ".", "index", "(", "line", ")", "fn_def", "=", "line", "[", "4", ":", "]", "fn_name", "=", "fn_def", ".", "split", "(", "'('", ")", "[", "0", "]", "function_info", "=", "{", "'name'", ":", "fn_name", "}", "extract", "=", "extract_code", "(", "':'", ",", "fn_def", ",", "pyfile_str", ",", "line_num", ")", "function_info", "[", "'definition'", "]", "=", "extract", "[", "'current_str'", "]", "# process docstring", "line_num", "=", "extract", "[", "'line_num'", "]", "+", "1", "doc_line", "=", "pyfile_str", "[", "line_num", "]", "if", "doc_line", ".", "startswith", "(", "\" '''\"", ")", ":", "comment_str", "=", "doc_line", "[", "7", ":", "]", "extract", "=", "extract_code", "(", "\"'''\"", ",", "comment_str", ",", "pyfile_str", ",", "line_num", ")", "function_info", "[", "'comments'", "]", "=", "extract", "[", "'current_str'", "]", "file_dict", "[", "'functions'", "]", ".", "append", "(", "function_info", ")", "return", "file_dict" ]
Process a Python source file with Google style docstring comments. Reads file header comment, function definitions, function docstrings. Returns dictionary encapsulation for subsequent writing. Args: pyfile_name (str): file name to read. Returns: Dictionary object containing summary comment, with a list of entries for each function.
[ "Process", "a", "Python", "source", "file", "with", "Google", "style", "docstring", "comments", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/docs/py2md.py#L33-L80
gbowerman/azurerm
docs/py2md.py
process_output
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
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()
[ "def", "process_output", "(", "meta_file", ",", "outfile_name", ",", "code_links", ")", ":", "# 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", "(", ")" ]
Create a markdown format documentation file. Args: meta_file (dict): Dictionary with documentation metadata. outfile_name (str): Markdown file to write to.
[ "Create", "a", "markdown", "format", "documentation", "file", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/docs/py2md.py#L83-L123
gbowerman/azurerm
docs/py2md.py
main
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--sourcedir', '-s', required=True, action='store', help='Source folder containing python files.') arg_parser.add_argument('--docfile', '-o', required=True, action='store', help='Name of markdown file to write output to.') arg_parser.add_argument('--projectname', '-n', required=False, action='store', help='Project name (optional, otherwise sourcedir will be used).') arg_parser.add_argument('--codelinks', '-c', required=False, action='store_true', help='Include links to source files (optional).') args = arg_parser.parse_args() source_dir = args.sourcedir doc_file = args.docfile code_links = args.codelinks proj_name = args.projectname if proj_name is None: proj_name = source_dir # main document dictionary meta_doc = {'header': proj_name + ' Technical Reference Guide'} meta_doc['modules'] = [] # process each file for source_file in glob.glob(source_dir + '/*.py'): if '__' in source_file: print('Skipping: ' + source_file) continue file_meta_doc = process_file(source_file) meta_doc['modules'].append(file_meta_doc) # create output file process_output(meta_doc, doc_file, code_links)
python
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--sourcedir', '-s', required=True, action='store', help='Source folder containing python files.') arg_parser.add_argument('--docfile', '-o', required=True, action='store', help='Name of markdown file to write output to.') arg_parser.add_argument('--projectname', '-n', required=False, action='store', help='Project name (optional, otherwise sourcedir will be used).') arg_parser.add_argument('--codelinks', '-c', required=False, action='store_true', help='Include links to source files (optional).') args = arg_parser.parse_args() source_dir = args.sourcedir doc_file = args.docfile code_links = args.codelinks proj_name = args.projectname if proj_name is None: proj_name = source_dir # main document dictionary meta_doc = {'header': proj_name + ' Technical Reference Guide'} meta_doc['modules'] = [] # process each file for source_file in glob.glob(source_dir + '/*.py'): if '__' in source_file: print('Skipping: ' + source_file) continue file_meta_doc = process_file(source_file) meta_doc['modules'].append(file_meta_doc) # create output file process_output(meta_doc, doc_file, code_links)
[ "def", "main", "(", ")", ":", "# validate command line arguments", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_parser", ".", "add_argument", "(", "'--sourcedir'", ",", "'-s'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Source folder containing python files.'", ")", "arg_parser", ".", "add_argument", "(", "'--docfile'", ",", "'-o'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Name of markdown file to write output to.'", ")", "arg_parser", ".", "add_argument", "(", "'--projectname'", ",", "'-n'", ",", "required", "=", "False", ",", "action", "=", "'store'", ",", "help", "=", "'Project name (optional, otherwise sourcedir will be used).'", ")", "arg_parser", ".", "add_argument", "(", "'--codelinks'", ",", "'-c'", ",", "required", "=", "False", ",", "action", "=", "'store_true'", ",", "help", "=", "'Include links to source files (optional).'", ")", "args", "=", "arg_parser", ".", "parse_args", "(", ")", "source_dir", "=", "args", ".", "sourcedir", "doc_file", "=", "args", ".", "docfile", "code_links", "=", "args", ".", "codelinks", "proj_name", "=", "args", ".", "projectname", "if", "proj_name", "is", "None", ":", "proj_name", "=", "source_dir", "# main document dictionary", "meta_doc", "=", "{", "'header'", ":", "proj_name", "+", "' Technical Reference Guide'", "}", "meta_doc", "[", "'modules'", "]", "=", "[", "]", "# process each file", "for", "source_file", "in", "glob", ".", "glob", "(", "source_dir", "+", "'/*.py'", ")", ":", "if", "'__'", "in", "source_file", ":", "print", "(", "'Skipping: '", "+", "source_file", ")", "continue", "file_meta_doc", "=", "process_file", "(", "source_file", ")", "meta_doc", "[", "'modules'", "]", ".", "append", "(", "file_meta_doc", ")", "# create output file", "process_output", "(", "meta_doc", ",", "doc_file", ",", "code_links", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/docs/py2md.py#L126-L162
gbowerman/azurerm
azurerm/acs.py
create_container_service
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
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)
[ "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'", ")", ":", "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", ")" ]
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.
[ "Create", "a", "new", "container", "service", "-", "include", "app_id", "and", "app_secret", "if", "using", "Kubernetes", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/acs.py#L7-L61
gbowerman/azurerm
azurerm/acs.py
delete_container_service
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
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)
[ "def", "delete_container_service", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "service_name", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "named", "container", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/acs.py#L64-L81
gbowerman/azurerm
azurerm/acs.py
get_container_service
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
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)
[ "def", "get_container_service", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "service_name", ")", ":", "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", ")" ]
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.
[ "Get", "details", "about", "an", "Azure", "Container", "Server" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/acs.py#L84-L101
gbowerman/azurerm
azurerm/acs.py
list_container_services
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
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)
[ "def", "list_container_services", "(", "access_token", ",", "subscription_id", ",", "resource_group", ")", ":", "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", ")" ]
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.
[ "List", "the", "container", "services", "in", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/acs.py#L119-L135
gbowerman/azurerm
azurerm/acs.py
list_container_services_sub
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
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)
[ "def", "list_container_services_sub", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.ContainerService/ContainerServices'", ",", "'?api-version='", ",", "ACS_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "container", "services", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/acs.py#L138-L152
gbowerman/azurerm
azurerm/storagerp.py
create_storage_account
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
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)
[ "def", "create_storage_account", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "account_name", ",", "location", ",", "storage_type", "=", "'Standard_LRS'", ")", ":", "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", ")" ]
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.
[ "Create", "a", "new", "storage", "account", "in", "the", "named", "resource", "group", "with", "the", "named", "location", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L7-L33
gbowerman/azurerm
azurerm/storagerp.py
delete_storage_account
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
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)
[ "def", "delete_storage_account", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "account_name", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "storage", "account", "in", "the", "specified", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L36-L53
gbowerman/azurerm
azurerm/storagerp.py
get_storage_account
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
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)
[ "def", "get_storage_account", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "account_name", ")", ":", "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", ")" ]
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.
[ "Get", "the", "properties", "for", "the", "named", "storage", "account", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L56-L73
gbowerman/azurerm
azurerm/storagerp.py
get_storage_account_keys
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
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)
[ "def", "get_storage_account_keys", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "account_name", ")", ":", "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", ")" ]
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.
[ "Get", "the", "access", "keys", "for", "the", "specified", "storage", "account", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L76-L94
gbowerman/azurerm
azurerm/storagerp.py
get_storage_usage
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
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)
[ "def", "get_storage_usage", "(", "access_token", ",", "subscription_id", ",", "location", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Storage/locations/'", ",", "location", ",", "'/usages'", ",", "'?api-version='", ",", "STORAGE_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "Returns", "storage", "usage", "and", "quota", "information", "for", "the", "specified", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L97-L112
gbowerman/azurerm
azurerm/storagerp.py
list_storage_accounts_rg
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
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)
[ "def", "list_storage_accounts_rg", "(", "access_token", ",", "subscription_id", ",", "rgname", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourcegroups/'", ",", "rgname", ",", "'/providers/Microsoft.Storage/storageAccounts'", ",", "'?api-version='", ",", "STORAGE_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "storage", "accounts", "in", "the", "specified", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L115-L131
gbowerman/azurerm
azurerm/storagerp.py
list_storage_accounts_sub
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
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)
[ "def", "list_storage_accounts_sub", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Storage/storageAccounts'", ",", "'?api-version='", ",", "STORAGE_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "storage", "accounts", "in", "the", "specified", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L134-L148
gbowerman/azurerm
examples/keyvault.py
main
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--add', '-a', action='store_true', default=False, help='add a key vault') arg_parser.add_argument('--delete', '-d', action='store_true', default=False, help='delete a key vault') arg_parser.add_argument('--name', '-n', required=True, action='store', help='Name') arg_parser.add_argument('--rgname', '-g', required=True, action='store', help='Resource Group Name') arg_parser.add_argument('--location', '-l', required=True, action='store', help='Location, e.g. eastus') arg_parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Print operational details') args = arg_parser.parse_args() name = args.name rgname = args.rgname location = args.location if args.add is True and args.delete is True: sys.exit('Specify --add or --delete, not both.') if args.add is False and args.delete is False: sys.exit('No operation specified, use --add or --delete.') if 'ACC_CLOUD' in os.environ and 'MSI_ENDPOINT' in os.environ: endpoint = os.environ['MSI_ENDPOINT'] else: sys.exit('Not running in cloud shell or MSI_ENDPOINT not set') # get Azure auth token if args.verbose is True: print('Getting Azure token from MSI endpoint..') access_token = azurerm.get_access_token_from_cli() if args.verbose is True: print('Getting Azure subscription ID from MSI endpoint..') subscription_id = azurerm.get_subscription_from_cli() # execute specified operation if args.add is True: # create a key vault # get Azure tenant ID if args.verbose is True: print('Getting list of tenant IDs...') tenants = azurerm.list_tenants(access_token) tenant_id = tenants['value'][0]['tenantId'] if args.verbose is True: print('My tenantId = ' + tenant_id) # get Graph object ID if args.verbose is True: print('Querying graph...') object_id = azurerm.get_object_id_from_graph() if args.verbose is True: print('My object ID = ' + object_id) # create key vault ret = azurerm.create_keyvault(access_token, subscription_id, rgname, name, location, tenant_id=tenant_id, object_id=object_id) if ret.status_code == 200: print('Successsfully created key vault: ' + name) print('Vault URI: ' + ret.json()['properties']['vaultUri']) else: print('Return code ' + str(ret.status_code) + ' from create_keyvault().') print(ret.text) # else delete named key vault else: ret = azurerm.delete_keyvault(access_token, subscription_id, rgname, name) if ret.status_code == 200: print('Successsfully deleted key vault: ' + name) else: print('Return code ' + str(ret.status_code) + ' from delete_keyvault().') print(ret.text)
python
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--add', '-a', action='store_true', default=False, help='add a key vault') arg_parser.add_argument('--delete', '-d', action='store_true', default=False, help='delete a key vault') arg_parser.add_argument('--name', '-n', required=True, action='store', help='Name') arg_parser.add_argument('--rgname', '-g', required=True, action='store', help='Resource Group Name') arg_parser.add_argument('--location', '-l', required=True, action='store', help='Location, e.g. eastus') arg_parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Print operational details') args = arg_parser.parse_args() name = args.name rgname = args.rgname location = args.location if args.add is True and args.delete is True: sys.exit('Specify --add or --delete, not both.') if args.add is False and args.delete is False: sys.exit('No operation specified, use --add or --delete.') if 'ACC_CLOUD' in os.environ and 'MSI_ENDPOINT' in os.environ: endpoint = os.environ['MSI_ENDPOINT'] else: sys.exit('Not running in cloud shell or MSI_ENDPOINT not set') # get Azure auth token if args.verbose is True: print('Getting Azure token from MSI endpoint..') access_token = azurerm.get_access_token_from_cli() if args.verbose is True: print('Getting Azure subscription ID from MSI endpoint..') subscription_id = azurerm.get_subscription_from_cli() # execute specified operation if args.add is True: # create a key vault # get Azure tenant ID if args.verbose is True: print('Getting list of tenant IDs...') tenants = azurerm.list_tenants(access_token) tenant_id = tenants['value'][0]['tenantId'] if args.verbose is True: print('My tenantId = ' + tenant_id) # get Graph object ID if args.verbose is True: print('Querying graph...') object_id = azurerm.get_object_id_from_graph() if args.verbose is True: print('My object ID = ' + object_id) # create key vault ret = azurerm.create_keyvault(access_token, subscription_id, rgname, name, location, tenant_id=tenant_id, object_id=object_id) if ret.status_code == 200: print('Successsfully created key vault: ' + name) print('Vault URI: ' + ret.json()['properties']['vaultUri']) else: print('Return code ' + str(ret.status_code) + ' from create_keyvault().') print(ret.text) # else delete named key vault else: ret = azurerm.delete_keyvault(access_token, subscription_id, rgname, name) if ret.status_code == 200: print('Successsfully deleted key vault: ' + name) else: print('Return code ' + str(ret.status_code) + ' from delete_keyvault().') print(ret.text)
[ "def", "main", "(", ")", ":", "# validate command line arguments", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_parser", ".", "add_argument", "(", "'--add'", ",", "'-a'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "'add a key vault'", ")", "arg_parser", ".", "add_argument", "(", "'--delete'", ",", "'-d'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "'delete a key vault'", ")", "arg_parser", ".", "add_argument", "(", "'--name'", ",", "'-n'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Name'", ")", "arg_parser", ".", "add_argument", "(", "'--rgname'", ",", "'-g'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Resource Group Name'", ")", "arg_parser", ".", "add_argument", "(", "'--location'", ",", "'-l'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Location, e.g. eastus'", ")", "arg_parser", ".", "add_argument", "(", "'--verbose'", ",", "'-v'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "'Print operational details'", ")", "args", "=", "arg_parser", ".", "parse_args", "(", ")", "name", "=", "args", ".", "name", "rgname", "=", "args", ".", "rgname", "location", "=", "args", ".", "location", "if", "args", ".", "add", "is", "True", "and", "args", ".", "delete", "is", "True", ":", "sys", ".", "exit", "(", "'Specify --add or --delete, not both.'", ")", "if", "args", ".", "add", "is", "False", "and", "args", ".", "delete", "is", "False", ":", "sys", ".", "exit", "(", "'No operation specified, use --add or --delete.'", ")", "if", "'ACC_CLOUD'", "in", "os", ".", "environ", "and", "'MSI_ENDPOINT'", "in", "os", ".", "environ", ":", "endpoint", "=", "os", ".", "environ", "[", "'MSI_ENDPOINT'", "]", "else", ":", "sys", ".", "exit", "(", "'Not running in cloud shell or MSI_ENDPOINT not set'", ")", "# get Azure auth token", "if", "args", ".", "verbose", "is", "True", ":", "print", "(", "'Getting Azure token from MSI endpoint..'", ")", "access_token", "=", "azurerm", ".", "get_access_token_from_cli", "(", ")", "if", "args", ".", "verbose", "is", "True", ":", "print", "(", "'Getting Azure subscription ID from MSI endpoint..'", ")", "subscription_id", "=", "azurerm", ".", "get_subscription_from_cli", "(", ")", "# execute specified operation", "if", "args", ".", "add", "is", "True", ":", "# create a key vault", "# get Azure tenant ID", "if", "args", ".", "verbose", "is", "True", ":", "print", "(", "'Getting list of tenant IDs...'", ")", "tenants", "=", "azurerm", ".", "list_tenants", "(", "access_token", ")", "tenant_id", "=", "tenants", "[", "'value'", "]", "[", "0", "]", "[", "'tenantId'", "]", "if", "args", ".", "verbose", "is", "True", ":", "print", "(", "'My tenantId = '", "+", "tenant_id", ")", "# get Graph object ID", "if", "args", ".", "verbose", "is", "True", ":", "print", "(", "'Querying graph...'", ")", "object_id", "=", "azurerm", ".", "get_object_id_from_graph", "(", ")", "if", "args", ".", "verbose", "is", "True", ":", "print", "(", "'My object ID = '", "+", "object_id", ")", "# create key vault", "ret", "=", "azurerm", ".", "create_keyvault", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "name", ",", "location", ",", "tenant_id", "=", "tenant_id", ",", "object_id", "=", "object_id", ")", "if", "ret", ".", "status_code", "==", "200", ":", "print", "(", "'Successsfully created key vault: '", "+", "name", ")", "print", "(", "'Vault URI: '", "+", "ret", ".", "json", "(", ")", "[", "'properties'", "]", "[", "'vaultUri'", "]", ")", "else", ":", "print", "(", "'Return code '", "+", "str", "(", "ret", ".", "status_code", ")", "+", "' from create_keyvault().'", ")", "print", "(", "ret", ".", "text", ")", "# else delete named key vault", "else", ":", "ret", "=", "azurerm", ".", "delete_keyvault", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "name", ")", "if", "ret", ".", "status_code", "==", "200", ":", "print", "(", "'Successsfully deleted key vault: '", "+", "name", ")", "else", ":", "print", "(", "'Return code '", "+", "str", "(", "ret", ".", "status_code", ")", "+", "' from delete_keyvault().'", ")", "print", "(", "ret", ".", "text", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/keyvault.py#L11-L84
gbowerman/azurerm
examples/create_vmss.py
main
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--name', '-n', required=True, action='store', help='Name of vmss') arg_parser.add_argument('--capacity', '-c', required=True, action='store', help='Number of VMs') arg_parser.add_argument('--location', '-l', action='store', help='Location, e.g. eastus') arg_parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Print operational details') args = arg_parser.parse_args() name = args.name location = args.location capacity = args.capacity # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: print("Error: Expecting azurermconfig.json in current folder") sys.exit() tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] # authenticate access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # create resource group print('Creating resource group: ' + name) rmreturn = azurerm.create_resource_group( access_token, subscription_id, name, location) print(rmreturn) # create NSG nsg_name = name + 'nsg' print('Creating NSG: ' + nsg_name) rmreturn = azurerm.create_nsg( access_token, subscription_id, name, nsg_name, location) nsg_id = rmreturn.json()['id'] print('nsg_id = ' + nsg_id) # create NSG rule nsg_rule = 'ssh' print('Creating NSG rule: ' + nsg_rule) rmreturn = azurerm.create_nsg_rule(access_token, subscription_id, name, nsg_name, nsg_rule, description='ssh rule', destination_range='22') #print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': '))) # create VNET vnetname = name + 'vnet' print('Creating VNet: ' + vnetname) rmreturn = azurerm.create_vnet(access_token, subscription_id, name, vnetname, location, nsg_id=nsg_id) print(rmreturn) # print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': '))) subnet_id = rmreturn.json()['properties']['subnets'][0]['id'] print('subnet_id = ' + subnet_id) # create public IP address public_ip_name = name + 'ip' dns_label = name + 'ip' print('Creating public IP address: ' + public_ip_name) rmreturn = azurerm.create_public_ip(access_token, subscription_id, name, public_ip_name, dns_label, location) print(rmreturn) ip_id = rmreturn.json()['id'] print('ip_id = ' + ip_id) # create load balancer with nat pool lb_name = vnetname + 'lb' print('Creating load balancer with nat pool: ' + lb_name) rmreturn = azurerm.create_lb_with_nat_pool(access_token, subscription_id, name, lb_name, ip_id, '50000', '50100', '22', location) be_pool_id = rmreturn.json()['properties']['backendAddressPools'][0]['id'] lb_pool_id = rmreturn.json()['properties']['inboundNatPools'][0]['id'] # create VMSS vmss_name = name vm_size = 'Standard_D1_v2' publisher = 'Canonical' offer = 'UbuntuServer' sku = '16.04-LTS' version = 'latest' username = 'azure' password = Haikunator().haikunate(delimiter=',') # creates random password print('Password = ' + password) print('Creating VMSS: ' + vmss_name) rmreturn = azurerm.create_vmss(access_token, subscription_id, name, vmss_name, vm_size, capacity, publisher, offer, sku, version, subnet_id, be_pool_id, lb_pool_id, location, username=username, password=password) print(rmreturn) print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': ')))
python
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--name', '-n', required=True, action='store', help='Name of vmss') arg_parser.add_argument('--capacity', '-c', required=True, action='store', help='Number of VMs') arg_parser.add_argument('--location', '-l', action='store', help='Location, e.g. eastus') arg_parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Print operational details') args = arg_parser.parse_args() name = args.name location = args.location capacity = args.capacity # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: print("Error: Expecting azurermconfig.json in current folder") sys.exit() tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] # authenticate access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # create resource group print('Creating resource group: ' + name) rmreturn = azurerm.create_resource_group( access_token, subscription_id, name, location) print(rmreturn) # create NSG nsg_name = name + 'nsg' print('Creating NSG: ' + nsg_name) rmreturn = azurerm.create_nsg( access_token, subscription_id, name, nsg_name, location) nsg_id = rmreturn.json()['id'] print('nsg_id = ' + nsg_id) # create NSG rule nsg_rule = 'ssh' print('Creating NSG rule: ' + nsg_rule) rmreturn = azurerm.create_nsg_rule(access_token, subscription_id, name, nsg_name, nsg_rule, description='ssh rule', destination_range='22') #print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': '))) # create VNET vnetname = name + 'vnet' print('Creating VNet: ' + vnetname) rmreturn = azurerm.create_vnet(access_token, subscription_id, name, vnetname, location, nsg_id=nsg_id) print(rmreturn) # print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': '))) subnet_id = rmreturn.json()['properties']['subnets'][0]['id'] print('subnet_id = ' + subnet_id) # create public IP address public_ip_name = name + 'ip' dns_label = name + 'ip' print('Creating public IP address: ' + public_ip_name) rmreturn = azurerm.create_public_ip(access_token, subscription_id, name, public_ip_name, dns_label, location) print(rmreturn) ip_id = rmreturn.json()['id'] print('ip_id = ' + ip_id) # create load balancer with nat pool lb_name = vnetname + 'lb' print('Creating load balancer with nat pool: ' + lb_name) rmreturn = azurerm.create_lb_with_nat_pool(access_token, subscription_id, name, lb_name, ip_id, '50000', '50100', '22', location) be_pool_id = rmreturn.json()['properties']['backendAddressPools'][0]['id'] lb_pool_id = rmreturn.json()['properties']['inboundNatPools'][0]['id'] # create VMSS vmss_name = name vm_size = 'Standard_D1_v2' publisher = 'Canonical' offer = 'UbuntuServer' sku = '16.04-LTS' version = 'latest' username = 'azure' password = Haikunator().haikunate(delimiter=',') # creates random password print('Password = ' + password) print('Creating VMSS: ' + vmss_name) rmreturn = azurerm.create_vmss(access_token, subscription_id, name, vmss_name, vm_size, capacity, publisher, offer, sku, version, subnet_id, be_pool_id, lb_pool_id, location, username=username, password=password) print(rmreturn) print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': ')))
[ "def", "main", "(", ")", ":", "# validate command line arguments", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_parser", ".", "add_argument", "(", "'--name'", ",", "'-n'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Name of vmss'", ")", "arg_parser", ".", "add_argument", "(", "'--capacity'", ",", "'-c'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Number of VMs'", ")", "arg_parser", ".", "add_argument", "(", "'--location'", ",", "'-l'", ",", "action", "=", "'store'", ",", "help", "=", "'Location, e.g. eastus'", ")", "arg_parser", ".", "add_argument", "(", "'--verbose'", ",", "'-v'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", "=", "'Print operational details'", ")", "args", "=", "arg_parser", ".", "parse_args", "(", ")", "name", "=", "args", ".", "name", "location", "=", "args", ".", "location", "capacity", "=", "args", ".", "capacity", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "print", "(", "\"Error: Expecting azurermconfig.json in current folder\"", ")", "sys", ".", "exit", "(", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "# authenticate", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# create resource group", "print", "(", "'Creating resource group: '", "+", "name", ")", "rmreturn", "=", "azurerm", ".", "create_resource_group", "(", "access_token", ",", "subscription_id", ",", "name", ",", "location", ")", "print", "(", "rmreturn", ")", "# create NSG", "nsg_name", "=", "name", "+", "'nsg'", "print", "(", "'Creating NSG: '", "+", "nsg_name", ")", "rmreturn", "=", "azurerm", ".", "create_nsg", "(", "access_token", ",", "subscription_id", ",", "name", ",", "nsg_name", ",", "location", ")", "nsg_id", "=", "rmreturn", ".", "json", "(", ")", "[", "'id'", "]", "print", "(", "'nsg_id = '", "+", "nsg_id", ")", "# create NSG rule", "nsg_rule", "=", "'ssh'", "print", "(", "'Creating NSG rule: '", "+", "nsg_rule", ")", "rmreturn", "=", "azurerm", ".", "create_nsg_rule", "(", "access_token", ",", "subscription_id", ",", "name", ",", "nsg_name", ",", "nsg_rule", ",", "description", "=", "'ssh rule'", ",", "destination_range", "=", "'22'", ")", "#print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': ')))", "# create VNET", "vnetname", "=", "name", "+", "'vnet'", "print", "(", "'Creating VNet: '", "+", "vnetname", ")", "rmreturn", "=", "azurerm", ".", "create_vnet", "(", "access_token", ",", "subscription_id", ",", "name", ",", "vnetname", ",", "location", ",", "nsg_id", "=", "nsg_id", ")", "print", "(", "rmreturn", ")", "# print(json.dumps(rmreturn.json(), sort_keys=False, indent=2, separators=(',', ': ')))", "subnet_id", "=", "rmreturn", ".", "json", "(", ")", "[", "'properties'", "]", "[", "'subnets'", "]", "[", "0", "]", "[", "'id'", "]", "print", "(", "'subnet_id = '", "+", "subnet_id", ")", "# create public IP address", "public_ip_name", "=", "name", "+", "'ip'", "dns_label", "=", "name", "+", "'ip'", "print", "(", "'Creating public IP address: '", "+", "public_ip_name", ")", "rmreturn", "=", "azurerm", ".", "create_public_ip", "(", "access_token", ",", "subscription_id", ",", "name", ",", "public_ip_name", ",", "dns_label", ",", "location", ")", "print", "(", "rmreturn", ")", "ip_id", "=", "rmreturn", ".", "json", "(", ")", "[", "'id'", "]", "print", "(", "'ip_id = '", "+", "ip_id", ")", "# create load balancer with nat pool", "lb_name", "=", "vnetname", "+", "'lb'", "print", "(", "'Creating load balancer with nat pool: '", "+", "lb_name", ")", "rmreturn", "=", "azurerm", ".", "create_lb_with_nat_pool", "(", "access_token", ",", "subscription_id", ",", "name", ",", "lb_name", ",", "ip_id", ",", "'50000'", ",", "'50100'", ",", "'22'", ",", "location", ")", "be_pool_id", "=", "rmreturn", ".", "json", "(", ")", "[", "'properties'", "]", "[", "'backendAddressPools'", "]", "[", "0", "]", "[", "'id'", "]", "lb_pool_id", "=", "rmreturn", ".", "json", "(", ")", "[", "'properties'", "]", "[", "'inboundNatPools'", "]", "[", "0", "]", "[", "'id'", "]", "# create VMSS", "vmss_name", "=", "name", "vm_size", "=", "'Standard_D1_v2'", "publisher", "=", "'Canonical'", "offer", "=", "'UbuntuServer'", "sku", "=", "'16.04-LTS'", "version", "=", "'latest'", "username", "=", "'azure'", "password", "=", "Haikunator", "(", ")", ".", "haikunate", "(", "delimiter", "=", "','", ")", "# creates random password", "print", "(", "'Password = '", "+", "password", ")", "print", "(", "'Creating VMSS: '", "+", "vmss_name", ")", "rmreturn", "=", "azurerm", ".", "create_vmss", "(", "access_token", ",", "subscription_id", ",", "name", ",", "vmss_name", ",", "vm_size", ",", "capacity", ",", "publisher", ",", "offer", ",", "sku", ",", "version", ",", "subnet_id", ",", "be_pool_id", ",", "lb_pool_id", ",", "location", ",", "username", "=", "username", ",", "password", "=", "password", ")", "print", "(", "rmreturn", ")", "print", "(", "json", ".", "dumps", "(", "rmreturn", ".", "json", "(", ")", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/create_vmss.py#L10-L110
gbowerman/azurerm
examples/list_storage.py
rgfromid
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
def rgfromid(idstr): '''get resource group name from the id string''' rgidx = idstr.find('resourceGroups/') providx = idstr.find('/providers/') return idstr[rgidx + 15:providx]
[ "def", "rgfromid", "(", "idstr", ")", ":", "rgidx", "=", "idstr", ".", "find", "(", "'resourceGroups/'", ")", "providx", "=", "idstr", ".", "find", "(", "'/providers/'", ")", "return", "idstr", "[", "rgidx", "+", "15", ":", "providx", "]" ]
get resource group name from the id string
[ "get", "resource", "group", "name", "from", "the", "id", "string" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_storage.py#L8-L12
gbowerman/azurerm
examples/list_storage.py
main
def main(): '''main routine''' # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit('Error: Expecting azurermconfig.json in current folder') tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # list storage accounts per sub sa_list = azurerm.list_storage_accounts_sub(access_token, subscription_id) # print(sa_list) for sta in sa_list['value']: print(sta['name'] + ', ' + sta['properties']['primaryLocation'] + ', ' + rgfromid(sta['id'])) # get storage account quota quota_info = azurerm.get_storage_usage(access_token, subscription_id) used = quota_info['value'][0]['currentValue'] limit = quota_info["value"][0]["limit"] print('\nUsing ' + str(used) + ' accounts out of ' + str(limit) + '.')
python
def main(): '''main routine''' # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit('Error: Expecting azurermconfig.json in current folder') tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # list storage accounts per sub sa_list = azurerm.list_storage_accounts_sub(access_token, subscription_id) # print(sa_list) for sta in sa_list['value']: print(sta['name'] + ', ' + sta['properties']['primaryLocation'] + ', ' + rgfromid(sta['id'])) # get storage account quota quota_info = azurerm.get_storage_usage(access_token, subscription_id) used = quota_info['value'][0]['currentValue'] limit = quota_info["value"][0]["limit"] print('\nUsing ' + str(used) + ' accounts out of ' + str(limit) + '.')
[ "def", "main", "(", ")", ":", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "'Error: Expecting azurermconfig.json in current folder'", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# list storage accounts per sub", "sa_list", "=", "azurerm", ".", "list_storage_accounts_sub", "(", "access_token", ",", "subscription_id", ")", "# print(sa_list)", "for", "sta", "in", "sa_list", "[", "'value'", "]", ":", "print", "(", "sta", "[", "'name'", "]", "+", "', '", "+", "sta", "[", "'properties'", "]", "[", "'primaryLocation'", "]", "+", "', '", "+", "rgfromid", "(", "sta", "[", "'id'", "]", ")", ")", "# get storage account quota", "quota_info", "=", "azurerm", ".", "get_storage_usage", "(", "access_token", ",", "subscription_id", ")", "used", "=", "quota_info", "[", "'value'", "]", "[", "0", "]", "[", "'currentValue'", "]", "limit", "=", "quota_info", "[", "\"value\"", "]", "[", "0", "]", "[", "\"limit\"", "]", "print", "(", "'\\nUsing '", "+", "str", "(", "used", ")", "+", "' accounts out of '", "+", "str", "(", "limit", ")", "+", "'.'", ")" ]
main routine
[ "main", "routine" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_storage.py#L14-L41
gbowerman/azurerm
examples/instanceviews.py
main
def main(): '''Main routine.''' # process arguments if len(sys.argv) < 3: usage() rgname = sys.argv[1] vmss = sys.argv[2] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit("Error: Expecting azurermconfig.json in current folder") tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # loop through resource groups instances = azurerm.list_vmss_vm_instance_view(access_token, subscription_id, rgname, vmss) print(json.dumps(instances, sort_keys=False, indent=2, separators=(',', ': ')))
python
def main(): '''Main routine.''' # process arguments if len(sys.argv) < 3: usage() rgname = sys.argv[1] vmss = sys.argv[2] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit("Error: Expecting azurermconfig.json in current folder") tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # loop through resource groups instances = azurerm.list_vmss_vm_instance_view(access_token, subscription_id, rgname, vmss) print(json.dumps(instances, sort_keys=False, indent=2, separators=(',', ': ')))
[ "def", "main", "(", ")", ":", "# process arguments", "if", "len", "(", "sys", ".", "argv", ")", "<", "3", ":", "usage", "(", ")", "rgname", "=", "sys", ".", "argv", "[", "1", "]", "vmss", "=", "sys", ".", "argv", "[", "2", "]", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "\"Error: Expecting azurermconfig.json in current folder\"", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# loop through resource groups", "instances", "=", "azurerm", ".", "list_vmss_vm_instance_view", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "vmss", ")", "print", "(", "json", ".", "dumps", "(", "instances", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/instanceviews.py#L13-L40
gbowerman/azurerm
azurerm/amsrp.py
check_media_service_name_availability
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
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)
[ "def", "check_media_service_name_availability", "(", "access_token", ",", "subscription_id", ",", "msname", ")", ":", "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", ")" ]
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.
[ "Check", "media", "service", "name", "availability", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L9-L27
gbowerman/azurerm
azurerm/amsrp.py
create_media_service_rg
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
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)
[ "def", "create_media_service_rg", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "location", ",", "stoname", ",", "msname", ")", ":", "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", ")" ]
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.
[ "Create", "a", "media", "service", "in", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L30-L58
gbowerman/azurerm
azurerm/amsrp.py
delete_media_service_rg
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
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)
[ "def", "delete_media_service_rg", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "msname", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "media", "service", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L61-L78
gbowerman/azurerm
azurerm/amsrp.py
list_media_endpoint_keys
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
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)
[ "def", "list_media_endpoint_keys", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "msname", ")", ":", "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", ")" ]
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.
[ "list", "the", "media", "endpoint", "keys", "in", "a", "media", "service" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L81-L99
gbowerman/azurerm
azurerm/amsrp.py
list_media_services
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
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)
[ "def", "list_media_services", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/microsoft.media/mediaservices?api-version='", ",", "MEDIA_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "media", "services", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L102-L115
gbowerman/azurerm
azurerm/amsrp.py
list_media_services_rg
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
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)
[ "def", "list_media_services_rg", "(", "access_token", ",", "subscription_id", ",", "rgname", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourceGroups/'", ",", "rgname", ",", "'/providers/microsoft.media/mediaservices?api-version='", ",", "MEDIA_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "media", "services", "in", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L118-L133
gbowerman/azurerm
azurerm/amsrp.py
get_ams_access_token
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
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)
[ "def", "get_ams_access_token", "(", "accountname", ",", "accountkey", ")", ":", "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", ")" ]
Get Media Services Authentication Token. Args: accountname (str): Azure Media Services account name. accountkey (str): Azure Media Services Key. Returns: HTTP response. JSON body.
[ "Get", "Media", "Services", "Authentication", "Token", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L136-L149
gbowerman/azurerm
azurerm/amsrp.py
create_media_asset
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
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)
[ "def", "create_media_asset", "(", "access_token", ",", "name", ",", "options", "=", "\"0\"", ")", ":", "path", "=", "'/Assets'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "'{\"Name\": \"'", "+", "name", "+", "'\", \"Options\": \"'", "+", "str", "(", "options", ")", "+", "'\"}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "Asset", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L404-L418
gbowerman/azurerm
azurerm/amsrp.py
create_media_assetfile
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
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)
[ "def", "create_media_assetfile", "(", "access_token", ",", "parent_asset_id", ",", "name", ",", "is_primary", "=", "\"false\"", ",", "is_encrypted", "=", "\"false\"", ",", "encryption_scheme", "=", "\"None\"", ",", "encryptionkey_id", "=", "\"None\"", ")", ":", "path", "=", "'/Files'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "if", "encryption_scheme", "==", "\"StorageEncryption\"", ":", "body", "=", "'{ \\\n\t\t\t\"IsEncrypted\": \"'", "+", "is_encrypted", "+", "'\", \\\n\t\t\t\"EncryptionScheme\": \"'", "+", "encryption_scheme", "+", "'\", \\\n\t\t\t\"EncryptionVersion\": \"'", "+", "\"1.0\"", "+", "'\", \\\n\t\t\t\"EncryptionKeyId\": \"'", "+", "encryptionkey_id", "+", "'\", \\\n\t\t\t\"IsPrimary\": \"'", "+", "is_primary", "+", "'\", \\\n\t\t\t\"MimeType\": \"video/mp4\", \\\n\t\t\t\"Name\": \"'", "+", "name", "+", "'\", \\\n\t\t\t\"ParentAssetId\": \"'", "+", "parent_asset_id", "+", "'\" \\\n\t\t}'", "else", ":", "body", "=", "'{ \\\n\t\t\t\"IsPrimary\": \"'", "+", "is_primary", "+", "'\", \\\n\t\t\t\"MimeType\": \"video/mp4\", \\\n\t\t\t\"Name\": \"'", "+", "name", "+", "'\", \\\n\t\t\t\"ParentAssetId\": \"'", "+", "parent_asset_id", "+", "'\" \\\n\t\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "Asset", "File", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L421-L457
gbowerman/azurerm
azurerm/amsrp.py
create_sas_locator
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
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)
[ "def", "create_sas_locator", "(", "access_token", ",", "asset_id", ",", "accesspolicy_id", ")", ":", "path", "=", "'/Locators'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "'{ \\\n\t\t\"AccessPolicyId\":\"'", "+", "accesspolicy_id", "+", "'\", \\\n\t\t\"AssetId\":\"'", "+", "asset_id", "+", "'\", \\\n\t\t\"Type\":1 \\\n\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "SAS", "Locator", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L460-L478
gbowerman/azurerm
azurerm/amsrp.py
create_asset_delivery_policy
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
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)
[ "def", "create_asset_delivery_policy", "(", "access_token", ",", "ams_account", ",", "key_delivery_url", ")", ":", "path", "=", "'/AssetDeliveryPolicies'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "'{ \\\n\t\t\"Name\":\"AssetDeliveryPolicy\", \\\n\t\t\"AssetDeliveryProtocol\":\"4\", \\\n\t\t\"AssetDeliveryPolicyType\":\"3\", \\\n\t\t\"AssetDeliveryConfiguration\":\"[{ \\\n\t\t\t\\\\\"Key\\\\\":\\\\\"2\\\\\", \\\n\t\t\t\\\\\"Value\\\\\":\\\\\"'", "+", "key_delivery_url", "+", "'\\\\\"}]\" \\\n\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "Asset", "Delivery", "Policy", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L481-L501
gbowerman/azurerm
azurerm/amsrp.py
create_contentkey_authorization_policy
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
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)
[ "def", "create_contentkey_authorization_policy", "(", "access_token", ",", "content", ")", ":", "path", "=", "'/ContentKeyAuthorizationPolicies'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "content", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "Content", "Key", "Authorization", "Policy", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L504-L517
gbowerman/azurerm
azurerm/amsrp.py
create_contentkey_authorization_policy_options
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
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")
[ "def", "create_contentkey_authorization_policy_options", "(", "access_token", ",", "key_delivery_type", "=", "\"2\"", ",", "name", "=", "\"HLS Open Authorization Policy\"", ",", "key_restriction_type", "=", "\"0\"", ")", ":", "path", "=", "'/ContentKeyAuthorizationPolicyOptions'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "'{ \\\n\t\t\"Name\":\"policy\",\\\n\t\t\"KeyDeliveryType\":\"'", "+", "key_delivery_type", "+", "'\", \\\n\t\t\"KeyDeliveryConfiguration\":\"\", \\\n\t\t\t\"Restrictions\":[{ \\\n\t\t\t\"Name\":\"'", "+", "name", "+", "'\", \\\n\t\t\t\"KeyRestrictionType\":\"'", "+", "key_restriction_type", "+", "'\", \\\n\t\t\t\"Requirements\":null \\\n\t\t}] \\\n\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ",", "\"json_only\"", ")" ]
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.
[ "Create", "Media", "Service", "Content", "Key", "Authorization", "Policy", "Options", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L520-L545
gbowerman/azurerm
azurerm/amsrp.py
create_ondemand_streaming_locator
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
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")
[ "def", "create_ondemand_streaming_locator", "(", "access_token", ",", "encoded_asset_id", ",", "pid", ",", "starttime", "=", "None", ")", ":", "path", "=", "'/Locators'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "if", "starttime", "is", "None", ":", "body", "=", "'{ \\\n\t\t\t\"AccessPolicyId\":\"'", "+", "pid", "+", "'\", \\\n\t\t\t\"AssetId\":\"'", "+", "encoded_asset_id", "+", "'\", \\\n\t\t\t\"Type\": \"2\" \\\n }'", "else", ":", "body", "=", "'{ \\\n\t\t\t\"AccessPolicyId\":\"'", "+", "pid", "+", "'\", \\\n\t\t\t\"AssetId\":\"'", "+", "encoded_asset_id", "+", "'\", \\\n\t\t\t\"StartTime\":\"'", "+", "str", "(", "starttime", ")", "+", "'\", \\\n\t\t\t\"Type\": \"2\" \\\n\t\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ",", "\"json_only\"", ")" ]
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.
[ "Create", "Media", "Service", "OnDemand", "Streaming", "Locator", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L548-L575
gbowerman/azurerm
azurerm/amsrp.py
create_asset_accesspolicy
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
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)
[ "def", "create_asset_accesspolicy", "(", "access_token", ",", "name", ",", "duration", ",", "permission", "=", "\"1\"", ")", ":", "path", "=", "'/AccessPolicies'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "'{ \\\n\t\t\"Name\": \"'", "+", "str", "(", "name", ")", "+", "'\", \\\n\t\t\"DurationInMinutes\": \"'", "+", "duration", "+", "'\", \\\n\t\t\"Permissions\": \"'", "+", "permission", "+", "'\" \\\n\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "Asset", "Access", "Policy", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L578-L597
gbowerman/azurerm
azurerm/amsrp.py
create_streaming_endpoint
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
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)
[ "def", "create_streaming_endpoint", "(", "access_token", ",", "name", ",", "description", "=", "\"New Streaming Endpoint\"", ",", "scale_units", "=", "\"1\"", ")", ":", "path", "=", "'/StreamingEndpoints'", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "body", "=", "'{ \\\n\t\t\"Id\":null, \\\n\t\t\"Name\":\"'", "+", "name", "+", "'\", \\\n\t\t\"Description\":\"'", "+", "description", "+", "'\", \\\n\t\t\"Created\":\"0001-01-01T00:00:00\", \\\n\t\t\"LastModified\":\"0001-01-01T00:00:00\", \\\n\t\t\"State\":null, \\\n\t\t\"HostName\":null, \\\n\t\t\"ScaleUnits\":\"'", "+", "scale_units", "+", "'\", \\\n\t\t\"CrossSiteAccessPolicies\":{ \\\n\t\t\t\"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>\", \\\n\t\t\t\"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>\" \\\n\t\t} \\\n\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Create", "Media", "Service", "Streaming", "Endpoint", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L600-L629
gbowerman/azurerm
azurerm/amsrp.py
scale_streaming_endpoint
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
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)
[ "def", "scale_streaming_endpoint", "(", "access_token", ",", "streaming_endpoint_id", ",", "scale_units", ")", ":", "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", ")" ]
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.
[ "Scale", "Media", "Service", "Streaming", "Endpoint", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L632-L648
gbowerman/azurerm
azurerm/amsrp.py
link_asset_content_key
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
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)
[ "def", "link_asset_content_key", "(", "access_token", ",", "asset_id", ",", "encryptionkey_id", ",", "ams_redirected_rest_endpoint", ")", ":", "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", ")" ]
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.
[ "Link", "Media", "Service", "Asset", "and", "Content", "Key", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L651-L669
gbowerman/azurerm
azurerm/amsrp.py
link_contentkey_authorization_policy
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
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")
[ "def", "link_contentkey_authorization_policy", "(", "access_token", ",", "ckap_id", ",", "options_id", ",", "ams_redirected_rest_endpoint", ")", ":", "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\"", ")" ]
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.
[ "Link", "Media", "Service", "Content", "Key", "Authorization", "Policy", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L693-L713
gbowerman/azurerm
azurerm/amsrp.py
add_authorization_policy
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
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)
[ "def", "add_authorization_policy", "(", "access_token", ",", "ck_id", ",", "oid", ")", ":", "path", "=", "'/ContentKeys'", "body", "=", "'{\"AuthorizationPolicyId\":\"'", "+", "oid", "+", "'\"}'", "return", "helper_add", "(", "access_token", ",", "ck_id", ",", "path", ",", "body", ")" ]
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.
[ "Add", "Media", "Service", "Authorization", "Policy", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L716-L729
gbowerman/azurerm
azurerm/amsrp.py
update_media_assetfile
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
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)
[ "def", "update_media_assetfile", "(", "access_token", ",", "parent_asset_id", ",", "asset_id", ",", "content_length", ",", "name", ")", ":", "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", "=", "'{ \\\n\t\t\"ContentFileSize\": \"'", "+", "str", "(", "content_length", ")", "+", "'\", \\\n\t\t\"Id\": \"'", "+", "asset_id", "+", "'\", \\\n\t\t\"MimeType\": \"video/mp4\", \\\n\t\t\"Name\": \"'", "+", "name", "+", "'\", \\\n\t\t\"ParentAssetId\": \"'", "+", "parent_asset_id", "+", "'\" \\\n\t}'", "return", "do_ams_patch", "(", "endpoint", ",", "full_path_encoded", ",", "body", ",", "access_token", ")" ]
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.
[ "Update", "Media", "Service", "Asset", "File", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L732-L756
gbowerman/azurerm
azurerm/amsrp.py
get_key_delivery_url
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
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)
[ "def", "get_key_delivery_url", "(", "access_token", ",", "ck_id", ",", "key_type", ")", ":", "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", ")" ]
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.
[ "Get", "Media", "Services", "Key", "Delivery", "URL", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L759-L774
gbowerman/azurerm
azurerm/amsrp.py
encode_mezzanine_asset
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
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)
[ "def", "encode_mezzanine_asset", "(", "access_token", ",", "processor_id", ",", "asset_id", ",", "output_assetname", ",", "json_profile", ")", ":", "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", "=", "'{ \\\n \t\t\"Name\":\"'", "+", "output_assetname", "+", "'\", \\\n \t\t\"InputMediaAssets\":[{ \\\n \t \t\t\"__metadata\":{ \\\n \t \t\t\t\"uri\":\"'", "+", "endpoint_assets", "+", "'\" \\\n \t \t\t} \\\n \t \t}], \\\n \t\t\"Tasks\":[{ \\\n \t \t\t\"Configuration\":\\''", "+", "json_profile", "+", "'\\', \\\n \t \t\t\"MediaProcessorId\":\"'", "+", "processor_id", "+", "'\", \\\n \t \t\t\"TaskBody\":\"<?xml version=\\\\\"1.0\\\\\" encoding=\\\\\"utf-16\\\\\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset assetCreationOptions=\\\\\"0\\\\\" assetName=\\\\\"'", "+", "output_assetname", "+", "'\\\\\">JobOutputAsset(0)</outputAsset></taskBody>\" \\\n \t\t}] \\\n\t}'", "return", "do_ams_post", "(", "endpoint", ",", "path", ",", "body", ",", "access_token", ")" ]
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.
[ "Get", "Media", "Service", "Encode", "Mezanine", "Asset", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L777-L808
gbowerman/azurerm
azurerm/amsrp.py
helper_add
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
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")
[ "def", "helper_add", "(", "access_token", ",", "ck_id", ",", "path", ",", "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\"", ")" ]
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.
[ "Helper", "Function", "to", "add", "strings", "to", "a", "URL", "path", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L844-L859
gbowerman/azurerm
azurerm/amsrp.py
helper_list
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
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)
[ "def", "helper_list", "(", "access_token", ",", "oid", ",", "path", ")", ":", "if", "oid", "!=", "\"\"", ":", "path", "=", "''", ".", "join", "(", "[", "path", ",", "\"('\"", ",", "oid", ",", "\"')\"", "]", ")", "endpoint", "=", "''", ".", "join", "(", "[", "ams_rest_endpoint", ",", "path", "]", ")", "return", "do_ams_get", "(", "endpoint", ",", "path", ",", "access_token", ")" ]
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.
[ "Helper", "Function", "to", "list", "a", "URL", "path", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L862-L876
gbowerman/azurerm
azurerm/amsrp.py
helper_delete
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
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)
[ "def", "helper_delete", "(", "access_token", ",", "oid", ",", "path", ")", ":", "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", ")" ]
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.
[ "Helper", "Function", "to", "delete", "a", "Object", "at", "a", "URL", "path", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L879-L893
gbowerman/azurerm
azurerm/amsrp.py
translate_job_state
def translate_job_state(code): '''AUX Function to translate the (numeric) state of a Job. Args: nr (int): A valid number to translate. Returns: HTTP response. JSON body. ''' code_description = "" if code == "0": code_description = "Queued" if code == "1": code_description = "Scheduled" if code == "2": code_description = "Processing" if code == "3": code_description = "Finished" if code == "4": code_description = "Error" if code == "5": code_description = "Canceled" if code == "6": code_description = "Canceling" return code_description
python
def translate_job_state(code): '''AUX Function to translate the (numeric) state of a Job. Args: nr (int): A valid number to translate. Returns: HTTP response. JSON body. ''' code_description = "" if code == "0": code_description = "Queued" if code == "1": code_description = "Scheduled" if code == "2": code_description = "Processing" if code == "3": code_description = "Finished" if code == "4": code_description = "Error" if code == "5": code_description = "Canceled" if code == "6": code_description = "Canceling" return code_description
[ "def", "translate_job_state", "(", "code", ")", ":", "code_description", "=", "\"\"", "if", "code", "==", "\"0\"", ":", "code_description", "=", "\"Queued\"", "if", "code", "==", "\"1\"", ":", "code_description", "=", "\"Scheduled\"", "if", "code", "==", "\"2\"", ":", "code_description", "=", "\"Processing\"", "if", "code", "==", "\"3\"", ":", "code_description", "=", "\"Finished\"", "if", "code", "==", "\"4\"", ":", "code_description", "=", "\"Error\"", "if", "code", "==", "\"5\"", ":", "code_description", "=", "\"Canceled\"", "if", "code", "==", "\"6\"", ":", "code_description", "=", "\"Canceling\"", "return", "code_description" ]
AUX Function to translate the (numeric) state of a Job. Args: nr (int): A valid number to translate. Returns: HTTP response. JSON body.
[ "AUX", "Function", "to", "translate", "the", "(", "numeric", ")", "state", "of", "a", "Job", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/amsrp.py#L915-L940
gbowerman/azurerm
azurerm/deployments.py
list_deployment_operations
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
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)
[ "def", "list_deployment_operations", "(", "access_token", ",", "subscription_id", ",", "rg_name", ",", "deployment_name", ")", ":", "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", ")" ]
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.
[ "List", "all", "operations", "involved", "in", "a", "given", "deployment", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/deployments.py#L7-L24
gbowerman/azurerm
azurerm/networkrp.py
create_lb_with_nat_pool
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
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)
[ "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", ")", ":", "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", ")" ]
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.
[ "Create", "a", "load", "balancer", "with", "inbound", "NAT", "pools", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L7-L49
gbowerman/azurerm
azurerm/networkrp.py
create_nic
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
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)
[ "def", "create_nic", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "nic_name", ",", "public_ip_id", ",", "subnet_id", ",", "location", ",", "nsg_id", "=", "None", ")", ":", "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", ")" ]
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.
[ "Create", "a", "network", "interface", "with", "an", "associated", "public", "ip", "address", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L52-L85
gbowerman/azurerm
azurerm/networkrp.py
create_nsg
def create_nsg(access_token, subscription_id, resource_group, nsg_name, location): '''Create network security group (use create_nsg_rule() to add rules to it). 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 new NSG. location (str): Azure data center location. E.g. westus. Returns: HTTP response. NSG JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkSecurityGroups/', nsg_name, '?api-version=', NETWORK_API]) nsg_body = {'location': location} body = json.dumps(nsg_body) return do_put(endpoint, body, access_token)
python
def create_nsg(access_token, subscription_id, resource_group, nsg_name, location): '''Create network security group (use create_nsg_rule() to add rules to it). 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 new NSG. location (str): Azure data center location. E.g. westus. Returns: HTTP response. NSG JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkSecurityGroups/', nsg_name, '?api-version=', NETWORK_API]) nsg_body = {'location': location} body = json.dumps(nsg_body) return do_put(endpoint, body, access_token)
[ "def", "create_nsg", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "nsg_name", ",", "location", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourceGroups/'", ",", "resource_group", ",", "'/providers/Microsoft.Network/networkSecurityGroups/'", ",", "nsg_name", ",", "'?api-version='", ",", "NETWORK_API", "]", ")", "nsg_body", "=", "{", "'location'", ":", "location", "}", "body", "=", "json", ".", "dumps", "(", "nsg_body", ")", "return", "do_put", "(", "endpoint", ",", "body", ",", "access_token", ")" ]
Create network security group (use create_nsg_rule() to add rules to it). 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 new NSG. location (str): Azure data center location. E.g. westus. Returns: HTTP response. NSG JSON body.
[ "Create", "network", "security", "group", "(", "use", "create_nsg_rule", "()", "to", "add", "rules", "to", "it", ")", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L88-L108
gbowerman/azurerm
azurerm/networkrp.py
create_nsg_rule
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
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)
[ "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'", ")", ":", "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", ")" ]
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.
[ "Create", "network", "security", "group", "rule", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L111-L153
gbowerman/azurerm
azurerm/networkrp.py
create_public_ip
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
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)
[ "def", "create_public_ip", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "public_ip_name", ",", "dns_label", ",", "location", ")", ":", "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", ")" ]
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.
[ "Create", "a", "public", "ip", "address", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L156-L181
gbowerman/azurerm
azurerm/networkrp.py
create_vnet
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
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)
[ "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", ")", ":", "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", ")" ]
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.
[ "Create", "a", "VNet", "with", "specified", "name", "and", "location", ".", "Optional", "subnet", "address", "prefix", ".." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L184-L216
gbowerman/azurerm
azurerm/networkrp.py
delete_load_balancer
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
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)
[ "def", "delete_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb_name", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "load", "balancer", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L219-L236
gbowerman/azurerm
azurerm/networkrp.py
delete_nic
def delete_nic(access_token, subscription_id, resource_group, nic_name): '''Delete 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. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkInterfaces/', nic_name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
python
def delete_nic(access_token, subscription_id, resource_group, nic_name): '''Delete 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. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/networkInterfaces/', nic_name, '?api-version=', NETWORK_API]) return do_delete(endpoint, access_token)
[ "def", "delete_nic", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "nic_name", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourceGroups/'", ",", "resource_group", ",", "'/providers/Microsoft.Network/networkInterfaces/'", ",", "nic_name", ",", "'?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_delete", "(", "endpoint", ",", "access_token", ")" ]
Delete 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.
[ "Delete", "a", "network", "interface", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L239-L256
gbowerman/azurerm
azurerm/networkrp.py
delete_nsg
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
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)
[ "def", "delete_nsg", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "nsg_name", ")", ":", "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", ")" ]
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.
[ "Delete", "network", "security", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L259-L276
gbowerman/azurerm
azurerm/networkrp.py
delete_nsg_rule
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
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)
[ "def", "delete_nsg_rule", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "nsg_name", ",", "nsg_rule_name", ")", ":", "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", ")" ]
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.
[ "Delete", "network", "security", "group", "rule", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L279-L298
gbowerman/azurerm
azurerm/networkrp.py
delete_public_ip
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
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)
[ "def", "delete_public_ip", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "public_ip_name", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "public", "ip", "addresses", "associated", "with", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L301-L318
gbowerman/azurerm
azurerm/networkrp.py
delete_vnet
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
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)
[ "def", "delete_vnet", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "name", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "virtual", "network", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L321-L338
gbowerman/azurerm
azurerm/networkrp.py
get_lb_nat_rule
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
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)
[ "def", "get_lb_nat_rule", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb_name", ",", "rule_name", ")", ":", "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", ")" ]
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.
[ "Get", "details", "about", "a", "load", "balancer", "inbound", "NAT", "rule", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L341-L360
gbowerman/azurerm
azurerm/networkrp.py
get_network_usage
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
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)
[ "def", "get_network_usage", "(", "access_token", ",", "subscription_id", ",", "location", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/locations/'", ",", "location", ",", "'/usages?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "network", "usage", "and", "limits", "for", "a", "location", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L383-L398
gbowerman/azurerm
azurerm/networkrp.py
get_nic
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
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)
[ "def", "get_nic", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "nic_name", ")", ":", "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", ")" ]
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.
[ "Get", "details", "about", "a", "network", "interface", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L401-L418
gbowerman/azurerm
azurerm/networkrp.py
get_public_ip
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
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)
[ "def", "get_public_ip", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "ip_name", ")", ":", "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", ")" ]
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.
[ "Get", "details", "about", "the", "named", "public", "ip", "address", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L421-L439
gbowerman/azurerm
azurerm/networkrp.py
get_vnet
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
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)
[ "def", "get_vnet", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vnet_name", ")", ":", "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", ")" ]
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.
[ "Get", "details", "about", "the", "named", "virtual", "network", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L442-L459
gbowerman/azurerm
azurerm/networkrp.py
list_asgs
def list_asgs(access_token, subscription_id, resource_group): '''Get details about the application security groups for 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. ASG JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/virtualNetworks/', '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
def list_asgs(access_token, subscription_id, resource_group): '''Get details about the application security groups for 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. ASG JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Network/virtualNetworks/', '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
[ "def", "list_asgs", "(", "access_token", ",", "subscription_id", ",", "resource_group", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourceGroups/'", ",", "resource_group", ",", "'/providers/Microsoft.Network/virtualNetworks/'", ",", "'?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
Get details about the application security groups for 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. ASG JSON body.
[ "Get", "details", "about", "the", "application", "security", "groups", "for", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L462-L478
gbowerman/azurerm
azurerm/networkrp.py
list_asgs_all
def list_asgs_all(access_token, subscription_id): '''Get details about the application security groups for a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. ASG JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/virtualNetworks/', '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
def list_asgs_all(access_token, subscription_id): '''Get details about the application security groups for a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. ASG JSON body. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/virtualNetworks/', '?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
[ "def", "list_asgs_all", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/virtualNetworks/'", ",", "'?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
Get details about the application security groups for a resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. ASG JSON body.
[ "Get", "details", "about", "the", "application", "security", "groups", "for", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L481-L495
gbowerman/azurerm
azurerm/networkrp.py
list_lb_nat_rules
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
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)
[ "def", "list_lb_nat_rules", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb_name", ")", ":", "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", ")" ]
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.
[ "List", "the", "inbound", "NAT", "rules", "for", "a", "load", "balancer", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L498-L515
gbowerman/azurerm
azurerm/networkrp.py
list_load_balancers
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
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)
[ "def", "list_load_balancers", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/'", ",", "'/loadBalancers?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "load", "balancers", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L518-L532
gbowerman/azurerm
azurerm/networkrp.py
list_nics
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
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)
[ "def", "list_nics", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/'", ",", "'/networkInterfaces?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "network", "interfaces", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L554-L568
gbowerman/azurerm
azurerm/networkrp.py
list_nsgs_all
def list_nsgs_all(access_token, subscription_id): '''List all network security groups in a subscription. Args: access_token (str): a valid Azure Authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of all network security groups in a subscription. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/', 'networkSEcurityGroups?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
python
def list_nsgs_all(access_token, subscription_id): '''List all network security groups in a subscription. Args: access_token (str): a valid Azure Authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of all network security groups in a subscription. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/providers/Microsoft.Network/', 'networkSEcurityGroups?api-version=', NETWORK_API]) return do_get(endpoint, access_token)
[ "def", "list_nsgs_all", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/'", ",", "'networkSEcurityGroups?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
List all network security groups in a subscription. Args: access_token (str): a valid Azure Authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of all network security groups in a subscription.
[ "List", "all", "network", "security", "groups", "in", "a", "subscription", ".", "Args", ":", "access_token", "(", "str", ")", ":", "a", "valid", "Azure", "Authentication", "token", ".", "subscription_id", "(", "str", ")", ":", "Azure", "subscription", "id", ".", "Returns", ":", "HTTP", "response", ".", "JSON", "body", "of", "all", "network", "security", "groups", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L608-L621
gbowerman/azurerm
azurerm/networkrp.py
list_vnets
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
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)
[ "def", "list_vnets", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Network/'", ",", "'/virtualNetworks?api-version='", ",", "NETWORK_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "the", "VNETs", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L643-L657
gbowerman/azurerm
azurerm/networkrp.py
update_load_balancer
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
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)
[ "def", "update_load_balancer", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "lb_name", ",", "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", ")" ]
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.
[ "Updates", "a", "load", "balancer", "model", "i", ".", "e", ".", "PUT", "an", "updated", "LB", "body", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L679-L697
gbowerman/azurerm
examples/list_quota.py
print_region_quota
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
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)
[ "def", "print_region_quota", "(", "access_token", ",", "sub_id", ",", "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", ")" ]
Print the Compute usage quota for a specific region
[ "Print", "the", "Compute", "usage", "quota", "for", "a", "specific", "region" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_quota.py#L9-L22
gbowerman/azurerm
examples/list_quota.py
main
def main(): '''Main routine.''' # check for single command argument if len(sys.argv) != 2: region = 'all' else: region = sys.argv[1] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit('Error: Expecting azurermconfig.json in current folder') tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] sub_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # print quota if region == 'all': # list locations locations = azurerm.list_locations(access_token, sub_id) for location in locations['value']: print_region_quota(access_token, sub_id, location['name']) else: print_region_quota(access_token, sub_id, region)
python
def main(): '''Main routine.''' # check for single command argument if len(sys.argv) != 2: region = 'all' else: region = sys.argv[1] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit('Error: Expecting azurermconfig.json in current folder') tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] sub_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # print quota if region == 'all': # list locations locations = azurerm.list_locations(access_token, sub_id) for location in locations['value']: print_region_quota(access_token, sub_id, location['name']) else: print_region_quota(access_token, sub_id, region)
[ "def", "main", "(", ")", ":", "# check for single command argument", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "region", "=", "'all'", "else", ":", "region", "=", "sys", ".", "argv", "[", "1", "]", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "'Error: Expecting azurermconfig.json in current folder'", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "sub_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# print quota", "if", "region", "==", "'all'", ":", "# list locations", "locations", "=", "azurerm", ".", "list_locations", "(", "access_token", ",", "sub_id", ")", "for", "location", "in", "locations", "[", "'value'", "]", ":", "print_region_quota", "(", "access_token", ",", "sub_id", ",", "location", "[", "'name'", "]", ")", "else", ":", "print_region_quota", "(", "access_token", ",", "sub_id", ",", "region", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_quota.py#L24-L53
gbowerman/azurerm
examples/list_pubs.py
main
def main(): '''Main routine.''' # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit("Error: Expecting azurermonfig.json in current folder") tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) ''' pubs = azurerm.list_publishers(access_token, subscription_id, 'southeastasia') for pub in pubs: # print(json.dumps(pub, sort_keys=False, indent=2, separators=(',', ': '))) print(pub['name']) offers = azurerm.list_offers(access_token, subscription_id, 'southeastasia', 'rancher') for offer in offers: print(json.dumps(offer, sort_keys=False, indent=2, separators=(',', ': '))) skus = azurerm.list_skus(access_token, subscription_id, 'southeastasia', 'rancher', 'rancheros') for sku in skus: print(sku['name']) ''' #print('Versions for CoreOS:') # versions = azurerm.list_sku_versions(access_token, subscription_id, 'eastasia', 'CoreOS', # 'CoreOS', 'Stable') versions = azurerm.list_sku_versions(access_token, subscription_id, 'eastus2', 'Canonical', 'UbuntuServer', '16.04-LTS') for version in versions: print(version['name'])
python
def main(): '''Main routine.''' # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit("Error: Expecting azurermonfig.json in current folder") tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) ''' pubs = azurerm.list_publishers(access_token, subscription_id, 'southeastasia') for pub in pubs: # print(json.dumps(pub, sort_keys=False, indent=2, separators=(',', ': '))) print(pub['name']) offers = azurerm.list_offers(access_token, subscription_id, 'southeastasia', 'rancher') for offer in offers: print(json.dumps(offer, sort_keys=False, indent=2, separators=(',', ': '))) skus = azurerm.list_skus(access_token, subscription_id, 'southeastasia', 'rancher', 'rancheros') for sku in skus: print(sku['name']) ''' #print('Versions for CoreOS:') # versions = azurerm.list_sku_versions(access_token, subscription_id, 'eastasia', 'CoreOS', # 'CoreOS', 'Stable') versions = azurerm.list_sku_versions(access_token, subscription_id, 'eastus2', 'Canonical', 'UbuntuServer', '16.04-LTS') for version in versions: print(version['name'])
[ "def", "main", "(", ")", ":", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "\"Error: Expecting azurermonfig.json in current folder\"", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "'''\n pubs = azurerm.list_publishers(access_token, subscription_id, 'southeastasia')\n for pub in pubs:\n # print(json.dumps(pub, sort_keys=False, indent=2, separators=(',', ': ')))\n print(pub['name'])\n\n offers = azurerm.list_offers(access_token, subscription_id, 'southeastasia', 'rancher')\n for offer in offers:\n print(json.dumps(offer, sort_keys=False, indent=2, separators=(',', ': ')))\n\n skus = azurerm.list_skus(access_token, subscription_id, 'southeastasia', 'rancher', 'rancheros')\n for sku in skus:\n print(sku['name'])\n '''", "#print('Versions for CoreOS:')", "# versions = azurerm.list_sku_versions(access_token, subscription_id, 'eastasia', 'CoreOS',", "# 'CoreOS', 'Stable')", "versions", "=", "azurerm", ".", "list_sku_versions", "(", "access_token", ",", "subscription_id", ",", "'eastus2'", ",", "'Canonical'", ",", "'UbuntuServer'", ",", "'16.04-LTS'", ")", "for", "version", "in", "versions", ":", "print", "(", "version", "[", "'name'", "]", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_pubs.py#L7-L42
gbowerman/azurerm
examples/deploytemplatecli.py
main
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--uri', '-u', required=True, action='store', help='Template URI') arg_parser.add_argument('--params', '-p', required=True, action='store', help='Parameters json file') arg_parser.add_argument('--rg', '-g', required=True, action='store', help='Resource Group name') arg_parser.add_argument('--sub', '-s', required=False, action='store', help='subscription id (optional)') args = arg_parser.parse_args() template_uri = args.uri params = args.params rgname = args.rg subscription_id = args.sub # load parameters file try: with open(params) as params_file: param_data = json.load(params_file) except FileNotFoundError: print('Error: Expecting ' + params + ' in current folder') sys.exit() access_token = azurerm.get_access_token_from_cli() if subscription_id is None: subscription_id = azurerm.get_subscription_from_cli() deployment_name = Haikunator().haikunate() print('Deployment name:' + deployment_name) deploy_return = azurerm.deploy_template_uri( access_token, subscription_id, rgname, deployment_name, template_uri, param_data) print(json.dumps(deploy_return.json(), sort_keys=False, indent=2, separators=(',', ': ')))
python
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--uri', '-u', required=True, action='store', help='Template URI') arg_parser.add_argument('--params', '-p', required=True, action='store', help='Parameters json file') arg_parser.add_argument('--rg', '-g', required=True, action='store', help='Resource Group name') arg_parser.add_argument('--sub', '-s', required=False, action='store', help='subscription id (optional)') args = arg_parser.parse_args() template_uri = args.uri params = args.params rgname = args.rg subscription_id = args.sub # load parameters file try: with open(params) as params_file: param_data = json.load(params_file) except FileNotFoundError: print('Error: Expecting ' + params + ' in current folder') sys.exit() access_token = azurerm.get_access_token_from_cli() if subscription_id is None: subscription_id = azurerm.get_subscription_from_cli() deployment_name = Haikunator().haikunate() print('Deployment name:' + deployment_name) deploy_return = azurerm.deploy_template_uri( access_token, subscription_id, rgname, deployment_name, template_uri, param_data) print(json.dumps(deploy_return.json(), sort_keys=False, indent=2, separators=(',', ': ')))
[ "def", "main", "(", ")", ":", "# validate command line arguments", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_parser", ".", "add_argument", "(", "'--uri'", ",", "'-u'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Template URI'", ")", "arg_parser", ".", "add_argument", "(", "'--params'", ",", "'-p'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Parameters json file'", ")", "arg_parser", ".", "add_argument", "(", "'--rg'", ",", "'-g'", ",", "required", "=", "True", ",", "action", "=", "'store'", ",", "help", "=", "'Resource Group name'", ")", "arg_parser", ".", "add_argument", "(", "'--sub'", ",", "'-s'", ",", "required", "=", "False", ",", "action", "=", "'store'", ",", "help", "=", "'subscription id (optional)'", ")", "args", "=", "arg_parser", ".", "parse_args", "(", ")", "template_uri", "=", "args", ".", "uri", "params", "=", "args", ".", "params", "rgname", "=", "args", ".", "rg", "subscription_id", "=", "args", ".", "sub", "# load parameters file", "try", ":", "with", "open", "(", "params", ")", "as", "params_file", ":", "param_data", "=", "json", ".", "load", "(", "params_file", ")", "except", "FileNotFoundError", ":", "print", "(", "'Error: Expecting '", "+", "params", "+", "' in current folder'", ")", "sys", ".", "exit", "(", ")", "access_token", "=", "azurerm", ".", "get_access_token_from_cli", "(", ")", "if", "subscription_id", "is", "None", ":", "subscription_id", "=", "azurerm", ".", "get_subscription_from_cli", "(", ")", "deployment_name", "=", "Haikunator", "(", ")", ".", "haikunate", "(", ")", "print", "(", "'Deployment name:'", "+", "deployment_name", ")", "deploy_return", "=", "azurerm", ".", "deploy_template_uri", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "deployment_name", ",", "template_uri", ",", "param_data", ")", "print", "(", "json", ".", "dumps", "(", "deploy_return", ".", "json", "(", ")", ",", "sort_keys", "=", "False", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/deploytemplatecli.py#L10-L47
gbowerman/azurerm
examples/delete_rg.py
main
def main(): '''Main routine.''' # check for single command argument if len(sys.argv) != 2: sys.exit('Usage: python ' + sys.argv[0] + ' rg_name') rgname = sys.argv[1] # if in Azure cloud shell, authenticate using the MSI endpoint if 'ACC_CLOUD' in os.environ and 'MSI_ENDPOINT' in os.environ: access_token = azurerm.get_access_token_from_cli() subscription_id = azurerm.get_subscription_from_cli() else: # load service principal details from a config file try: with open('azurermconfig.json') as configfile: configdata = json.load(configfile) except FileNotFoundError: sys.exit('Error: Expecting azurermconfig.json in current folder') tenant_id = configdata['tenantId'] app_id = configdata['appId'] app_secret = configdata['appSecret'] subscription_id = configdata['subscriptionId'] # authenticate access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # delete a resource group rgreturn = azurerm.delete_resource_group(access_token, subscription_id, rgname) print(rgreturn)
python
def main(): '''Main routine.''' # check for single command argument if len(sys.argv) != 2: sys.exit('Usage: python ' + sys.argv[0] + ' rg_name') rgname = sys.argv[1] # if in Azure cloud shell, authenticate using the MSI endpoint if 'ACC_CLOUD' in os.environ and 'MSI_ENDPOINT' in os.environ: access_token = azurerm.get_access_token_from_cli() subscription_id = azurerm.get_subscription_from_cli() else: # load service principal details from a config file try: with open('azurermconfig.json') as configfile: configdata = json.load(configfile) except FileNotFoundError: sys.exit('Error: Expecting azurermconfig.json in current folder') tenant_id = configdata['tenantId'] app_id = configdata['appId'] app_secret = configdata['appSecret'] subscription_id = configdata['subscriptionId'] # authenticate access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # delete a resource group rgreturn = azurerm.delete_resource_group(access_token, subscription_id, rgname) print(rgreturn)
[ "def", "main", "(", ")", ":", "# check for single command argument", "if", "len", "(", "sys", ".", "argv", ")", "!=", "2", ":", "sys", ".", "exit", "(", "'Usage: python '", "+", "sys", ".", "argv", "[", "0", "]", "+", "' rg_name'", ")", "rgname", "=", "sys", ".", "argv", "[", "1", "]", "# if in Azure cloud shell, authenticate using the MSI endpoint", "if", "'ACC_CLOUD'", "in", "os", ".", "environ", "and", "'MSI_ENDPOINT'", "in", "os", ".", "environ", ":", "access_token", "=", "azurerm", ".", "get_access_token_from_cli", "(", ")", "subscription_id", "=", "azurerm", ".", "get_subscription_from_cli", "(", ")", "else", ":", "# load service principal details from a config file ", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "configfile", ":", "configdata", "=", "json", ".", "load", "(", "configfile", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "'Error: Expecting azurermconfig.json in current folder'", ")", "tenant_id", "=", "configdata", "[", "'tenantId'", "]", "app_id", "=", "configdata", "[", "'appId'", "]", "app_secret", "=", "configdata", "[", "'appSecret'", "]", "subscription_id", "=", "configdata", "[", "'subscriptionId'", "]", "# authenticate", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# delete a resource group", "rgreturn", "=", "azurerm", ".", "delete_resource_group", "(", "access_token", ",", "subscription_id", ",", "rgname", ")", "print", "(", "rgreturn", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/delete_rg.py#L9-L38
gbowerman/azurerm
examples/list_locations.py
main
def main(): '''Main routine.''' # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit("Error: Expecting azurermconfig.json in current folder") tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # list locations locations = azurerm.list_locations(access_token, subscription_id) for location in locations['value']: print(location['name'] + ', Display Name: ' + location['displayName'] + ', Coords: ' + location['latitude'] + ', ' + location['longitude'])
python
def main(): '''Main routine.''' # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit("Error: Expecting azurermconfig.json in current folder") tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) # list locations locations = azurerm.list_locations(access_token, subscription_id) for location in locations['value']: print(location['name'] + ', Display Name: ' + location['displayName'] + ', Coords: ' + location['latitude'] + ', ' + location['longitude'])
[ "def", "main", "(", ")", ":", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "\"Error: Expecting azurermconfig.json in current folder\"", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "# list locations", "locations", "=", "azurerm", ".", "list_locations", "(", "access_token", ",", "subscription_id", ")", "for", "location", "in", "locations", "[", "'value'", "]", ":", "print", "(", "location", "[", "'name'", "]", "+", "', Display Name: '", "+", "location", "[", "'displayName'", "]", "+", "', Coords: '", "+", "location", "[", "'latitude'", "]", "+", "', '", "+", "location", "[", "'longitude'", "]", ")" ]
Main routine.
[ "Main", "routine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_locations.py#L7-L30
gbowerman/azurerm
examples/scale_vmss.py
main
def main(): '''main routine''' # process arguments if len(sys.argv) < 4: usage() rgname = sys.argv[1] vmss_name = sys.argv[2] capacity = sys.argv[3] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: print("Error: Expecting azurermconfig.json in current folder") sys.exit() tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) scaleoutput = azurerm.scale_vmss(access_token, subscription_id, rgname, vmss_name, capacity) print(scaleoutput.text)
python
def main(): '''main routine''' # process arguments if len(sys.argv) < 4: usage() rgname = sys.argv[1] vmss_name = sys.argv[2] capacity = sys.argv[3] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: print("Error: Expecting azurermconfig.json in current folder") sys.exit() tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) scaleoutput = azurerm.scale_vmss(access_token, subscription_id, rgname, vmss_name, capacity) print(scaleoutput.text)
[ "def", "main", "(", ")", ":", "# process arguments", "if", "len", "(", "sys", ".", "argv", ")", "<", "4", ":", "usage", "(", ")", "rgname", "=", "sys", ".", "argv", "[", "1", "]", "vmss_name", "=", "sys", ".", "argv", "[", "2", "]", "capacity", "=", "sys", ".", "argv", "[", "3", "]", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "print", "(", "\"Error: Expecting azurermconfig.json in current folder\"", ")", "sys", ".", "exit", "(", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "scaleoutput", "=", "azurerm", ".", "scale_vmss", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "vmss_name", ",", "capacity", ")", "print", "(", "scaleoutput", ".", "text", ")" ]
main routine
[ "main", "routine" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/scale_vmss.py#L12-L39
gbowerman/azurerm
examples/list_vmss_vms.py
main
def main(): '''main routine''' # process arguments if len(sys.argv) < 3: usage() rgname = sys.argv[1] vmss_name = sys.argv[2] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit('Error: Expecting azurermonfig.json in current folder') tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) instanceviewlist = azurerm.list_vmss_vm_instance_view(access_token, subscription_id, rgname, vmss_name) for vmi in instanceviewlist['value']: instance_id = vmi['instanceId'] upgrade_domain = vmi['properties']['instanceView']['platformUpdateDomain'] fault_domain = vmi['properties']['instanceView']['platformFaultDomain'] print('Instance ID: ' + instance_id + ', UD: ' + str(upgrade_domain) + ', FD: ' + str(fault_domain))
python
def main(): '''main routine''' # process arguments if len(sys.argv) < 3: usage() rgname = sys.argv[1] vmss_name = sys.argv[2] # Load Azure app defaults try: with open('azurermconfig.json') as config_file: config_data = json.load(config_file) except FileNotFoundError: sys.exit('Error: Expecting azurermonfig.json in current folder') tenant_id = config_data['tenantId'] app_id = config_data['appId'] app_secret = config_data['appSecret'] subscription_id = config_data['subscriptionId'] access_token = azurerm.get_access_token(tenant_id, app_id, app_secret) instanceviewlist = azurerm.list_vmss_vm_instance_view(access_token, subscription_id, rgname, vmss_name) for vmi in instanceviewlist['value']: instance_id = vmi['instanceId'] upgrade_domain = vmi['properties']['instanceView']['platformUpdateDomain'] fault_domain = vmi['properties']['instanceView']['platformFaultDomain'] print('Instance ID: ' + instance_id + ', UD: ' + str(upgrade_domain) + ', FD: ' + str(fault_domain))
[ "def", "main", "(", ")", ":", "# process arguments", "if", "len", "(", "sys", ".", "argv", ")", "<", "3", ":", "usage", "(", ")", "rgname", "=", "sys", ".", "argv", "[", "1", "]", "vmss_name", "=", "sys", ".", "argv", "[", "2", "]", "# Load Azure app defaults", "try", ":", "with", "open", "(", "'azurermconfig.json'", ")", "as", "config_file", ":", "config_data", "=", "json", ".", "load", "(", "config_file", ")", "except", "FileNotFoundError", ":", "sys", ".", "exit", "(", "'Error: Expecting azurermonfig.json in current folder'", ")", "tenant_id", "=", "config_data", "[", "'tenantId'", "]", "app_id", "=", "config_data", "[", "'appId'", "]", "app_secret", "=", "config_data", "[", "'appSecret'", "]", "subscription_id", "=", "config_data", "[", "'subscriptionId'", "]", "access_token", "=", "azurerm", ".", "get_access_token", "(", "tenant_id", ",", "app_id", ",", "app_secret", ")", "instanceviewlist", "=", "azurerm", ".", "list_vmss_vm_instance_view", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "vmss_name", ")", "for", "vmi", "in", "instanceviewlist", "[", "'value'", "]", ":", "instance_id", "=", "vmi", "[", "'instanceId'", "]", "upgrade_domain", "=", "vmi", "[", "'properties'", "]", "[", "'instanceView'", "]", "[", "'platformUpdateDomain'", "]", "fault_domain", "=", "vmi", "[", "'properties'", "]", "[", "'instanceView'", "]", "[", "'platformFaultDomain'", "]", "print", "(", "'Instance ID: '", "+", "instance_id", "+", "', UD: '", "+", "str", "(", "upgrade_domain", ")", "+", "', FD: '", "+", "str", "(", "fault_domain", ")", ")" ]
main routine
[ "main", "routine" ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/examples/list_vmss_vms.py#L13-L44
gbowerman/azurerm
azurerm/computerp.py
create_as
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
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)
[ "def", "create_as", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "as_name", ",", "update_domains", ",", "fault_domains", ",", "location", ")", ":", "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", ")" ]
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.
[ "Create", "availability", "set", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L9-L35
gbowerman/azurerm
azurerm/computerp.py
create_vm
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
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)
[ "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", ")", ":", "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", ")" ]
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.
[ "Create", "a", "new", "Azure", "virtual", "machine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L38-L104
gbowerman/azurerm
azurerm/computerp.py
create_vmss
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
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)
[ "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", ")", ":", "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", ")" ]
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.
[ "Create", "virtual", "machine", "scale", "set", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L107-L193
gbowerman/azurerm
azurerm/computerp.py
delete_as
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
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)
[ "def", "delete_as", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "as_name", ")", ":", "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", ")" ]
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.
[ "Delete", "availability", "set", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L217-L234
gbowerman/azurerm
azurerm/computerp.py
delete_vm
def delete_vm(access_token, subscription_id, resource_group, vm_name): '''Delete a 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 virtual machine. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachines/', vm_name, '?api-version=', COMP_API]) return do_delete(endpoint, access_token)
python
def delete_vm(access_token, subscription_id, resource_group, vm_name): '''Delete a 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 virtual machine. Returns: HTTP response. ''' endpoint = ''.join([get_rm_endpoint(), '/subscriptions/', subscription_id, '/resourceGroups/', resource_group, '/providers/Microsoft.Compute/virtualMachines/', vm_name, '?api-version=', COMP_API]) return do_delete(endpoint, access_token)
[ "def", "delete_vm", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vm_name", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourceGroups/'", ",", "resource_group", ",", "'/providers/Microsoft.Compute/virtualMachines/'", ",", "vm_name", ",", "'?api-version='", ",", "COMP_API", "]", ")", "return", "do_delete", "(", "endpoint", ",", "access_token", ")" ]
Delete a 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 virtual machine. Returns: HTTP response.
[ "Delete", "a", "virtual", "machine", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L237-L254
gbowerman/azurerm
azurerm/computerp.py
delete_vmss
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
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)
[ "def", "delete_vmss", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vmss_name", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "virtual", "machine", "scale", "set", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L257-L274
gbowerman/azurerm
azurerm/computerp.py
delete_vmss_vms
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
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)
[ "def", "delete_vmss_vms", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vmss_name", ",", "vm_ids", ")", ":", "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", ")" ]
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.
[ "Delete", "a", "VM", "in", "a", "VM", "Scale", "Set", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L277-L296
gbowerman/azurerm
azurerm/computerp.py
get_compute_usage
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
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)
[ "def", "get_compute_usage", "(", "access_token", ",", "subscription_id", ",", "location", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.compute/locations/'", ",", "location", ",", "'/usages?api-version='", ",", "COMP_API", "]", ")", "return", "do_get", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "compute", "usage", "and", "limits", "for", "a", "location", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L299-L314
gbowerman/azurerm
azurerm/computerp.py
get_vm
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
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)
[ "def", "get_vm", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vm_name", ")", ":", "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", ")" ]
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.
[ "Get", "virtual", "machine", "details", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L317-L334
gbowerman/azurerm
azurerm/computerp.py
get_vm_extension
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
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)
[ "def", "get_vm_extension", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vm_name", ",", "extension_name", ")", ":", "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", ")" ]
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.
[ "Get", "details", "about", "a", "VM", "extension", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L337-L356
gbowerman/azurerm
azurerm/computerp.py
get_vmss
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
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)
[ "def", "get_vmss", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vmss_name", ")", ":", "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", ")" ]
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.
[ "Get", "virtual", "machine", "scale", "set", "details", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L379-L396
gbowerman/azurerm
azurerm/computerp.py
get_vmss_vm
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
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)
[ "def", "get_vmss_vm", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vmss_name", ",", "instance_id", ")", ":", "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", ")" ]
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.
[ "Get", "individual", "VMSS", "VM", "details", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L479-L498
gbowerman/azurerm
azurerm/computerp.py
get_as
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
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)
[ "def", "get_as", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "as_name", ")", ":", "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", ")" ]
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.
[ "Get", "availability", "set", "details", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L546-L563
gbowerman/azurerm
azurerm/computerp.py
list_as_sub
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
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)
[ "def", "list_as_sub", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Compute/availabilitySets'", ",", "'?api-version='", ",", "COMP_API", "]", ")", "return", "do_get_next", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "availability", "sets", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L585-L599
gbowerman/azurerm
azurerm/computerp.py
list_vm_images_sub
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
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)
[ "def", "list_vm_images_sub", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Compute/images'", ",", "'?api-version='", ",", "COMP_API", "]", ")", "return", "do_get_next", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "VM", "images", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L602-L616
gbowerman/azurerm
azurerm/computerp.py
list_vms
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
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)
[ "def", "list_vms", "(", "access_token", ",", "subscription_id", ",", "resource_group", ")", ":", "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", ")" ]
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.
[ "List", "VMs", "in", "a", "resource", "group", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L619-L635
gbowerman/azurerm
azurerm/computerp.py
list_vms_sub
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
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)
[ "def", "list_vms_sub", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Compute/virtualMachines'", ",", "'?api-version='", ",", "COMP_API", "]", ")", "return", "do_get_next", "(", "endpoint", ",", "access_token", ")" ]
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.
[ "List", "VMs", "in", "a", "subscription", "." ]
train
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L638-L652