  def CreateInstanceFromRequest(
      self, request_body: Dict[str, str],
      zone: Optional[str] = None) -> 'GoogleComputeInstance':
    """Creates an instance from an instance.insert request body.

    Args:
      request_body: Insert instance request body at
          https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert#request-body  # pylint: disable=line-too-long
      zone: Compute zone to start the instance in, default is self.default_zone.

    Returns:
      Compute instance object.

    Raises:
      ResourceAlreadyExistsError: If an instance with the same name already exists.
      ResourceCreationError: If an error occurs creating the instance.
      InvalidNameError: If instance name is invalid.
    """
    instance_name = request_body['name']
    if not common.COMPUTE_RFC1035_REGEX.match(instance_name):
      raise errors.InvalidNameError(
          'Instance name {0:s} does not comply with {1:s}.'.format(
              instance_name, common.COMPUTE_RFC1035_REGEX.pattern),
          __name__)
    gce_instance_client = self.GceApi().instances() # pylint: disable=no-member
    compute_zone = zone if zone else self.default_zone
    params = {
        'project': self.project_id, 'zone': compute_zone, 'body': request_body
    }
    # Safe to unpack response is not paged.
    try:
      response = common.ExecuteRequest(gce_instance_client, 'insert', params)[0]
      self.BlockOperation(response, zone=compute_zone)
    except HttpError as e:
      if e.resp.status == 409:
        msg = (
            'An instance with the name {0:s} already exists '
            'in project {1:s}').format(instance_name, self.project_id)
        raise errors.ResourceAlreadyExistsError(msg, __name__) from e
      msg = 'Error while creating instance {0:s}'.format(instance_name)
      raise errors.ResourceCreationError(msg, __name__) from e
    return GoogleComputeInstance(
        project_id=self.project_id, zone=compute_zone, name=instance_name)
Creates an instance from an instance.insert request body.

Args:
request_body: Insert instance request body at
https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert#request-body  # pylint: disable=line-too-long
zone: Compute zone to start the instance in, default is self.default_zone.

Returns:
Compute instance object.

Raises:
ResourceAlreadyExistsError: If an instance with the same name already exists.
ResourceCreationError: If an error occurs creating the instance.
InvalidNameError: If instance name is invalid.
libcloudforensics/providers/gcp/internal/compute.py