def create_instance(credentials, project, zone, name,<EOL>startup_script=None, startup_script_url=None,<EOL>metadata=None,<EOL>machine_type='<STR_LIT>', tags=None,<EOL>disk_size_gb=<NUM_LIT:10>, wait_until_done=False):
if startup_script is not None and startup_script_url is not None:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>access_token = credentials.get_access_token()<EOL>if metadata is None:<EOL><INDENT>metadata = {}<EOL><DEDENT>meta_items = [{'<STR_LIT:key>': k, '<STR_LIT:value>': v} for k, v in metadata.items()]<EOL>if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>if startup_script is not None:<EOL><INDENT>meta_items.insert(<EOL><NUM_LIT:0>, {'<STR_LIT:key>': '<STR_LIT>', '<STR_LIT:value>': startup_script}<EOL>)<EOL><DEDENT>elif startup_script_url is not None:<EOL><INDENT>meta_items.insert(<EOL><NUM_LIT:0>, {'<STR_LIT:key>': '<STR_LIT>', '<STR_LIT:value>': startup_script_url})<EOL><DEDENT>payload = {<EOL>"<STR_LIT:name>": name,<EOL>"<STR_LIT>": "<STR_LIT>" % (project, zone),<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>% (project, zone, machine_type),<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": meta_items<EOL>},<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": tags<EOL>},<EOL>"<STR_LIT>": [<EOL>{<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT>": name,<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>" % (project, zone),<EOL>"<STR_LIT>": str(disk_size_gb)<EOL>}<EOL>}<EOL>],<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": [<EOL>{<EOL>"<STR_LIT>": "<STR_LIT>" % project,<EOL>"<STR_LIT>": "<STR_LIT>" % (project, zone[:-<NUM_LIT:2>]),<EOL>"<STR_LIT>": [<EOL>{<EOL>"<STR_LIT:name>": "<STR_LIT>", "<STR_LIT:type>": "<STR_LIT>"<EOL>}<EOL>]<EOL>}<EOL>],<EOL>"<STR_LIT:description>": "<STR_LIT>",<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": True<EOL>},<EOL>"<STR_LIT>": [<EOL>{<EOL>"<STR_LIT:email>": "<STR_LIT:default>",<EOL>"<STR_LIT>": [<EOL>'<STR_LIT>',<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"<EOL>]<EOL>}<EOL>]<EOL>}<EOL>headers = {<EOL>'<STR_LIT>': '<STR_LIT>' % access_token.access_token<EOL>}<EOL>_LOGGER.debug('<STR_LIT>' % access_token.access_token)<EOL>_LOGGER.debug('<STR_LIT>', json.dumps(payload, sort_keys=True, indent=<NUM_LIT:4>))<EOL>r = requests.post('<STR_LIT>'<EOL>'<STR_LIT>' % (project, zone),<EOL>headers=headers, json=payload)<EOL>r.raise_for_status()<EOL>op_name = r.json()['<STR_LIT:name>']<EOL>_LOGGER.info('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>r.status_code)<EOL>if wait_until_done:<EOL><INDENT>_LOGGER.info('<STR_LIT>')<EOL>wait_for_zone_op(access_token, project, zone, op_name)<EOL><DEDENT>return op_name<EOL>
Create instance with startup script.

    TODO: docstring