Interface InstanceApi


  • @Path("/instances")
    @Consumes("application/json")
    public interface InstanceApi
    • Method Detail

      • get

        @Named("Instances:get")
        @GET
        @Path("/{instance}")
        @Nullable
        Instance get​(@PathParam("instance")
                     String instance)
        Returns an instance by name or null if not found.
      • create

        @Named("Instances:insert")
        @POST
        @Produces("application/json")
        Operation create​(NewInstance template)
        Creates a instance resource in the specified project using the data included in the request.
        Parameters:
        template - the instance template
        Returns:
        an Operation resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • delete

        @Named("Instances:delete")
        @DELETE
        @Path("/{instance}")
        @Nullable
        Operation delete​(@PathParam("instance")
                         String instance)
        Deletes an instance by name and returns the operation in progress, or null if not found.
      • addAccessConfigToNic

        @Named("Instances:addAccessConfig")
        @POST
        @Produces("application/json")
        @Path("/{instance}/addAccessConfig")
        Operation addAccessConfigToNic​(@PathParam("instance")
                                       String instance,
                                       Instance.NetworkInterface.AccessConfig accessConfig,
                                       @QueryParam("networkInterface")
                                       String networkInterfaceName)
        Adds an access config to an instance's network interface.
        Parameters:
        instance - the instance name.
        accessConfig - the AccessConfig to add.
        networkInterfaceName - network interface name.
        Returns:
        an Operation resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • deleteAccessConfigFromNic

        @Named("Instances:deleteAccessConfig")
        @POST
        @Path("/{instance}/deleteAccessConfig")
        Operation deleteAccessConfigFromNic​(@PathParam("instance")
                                            String instance,
                                            @QueryParam("accessConfig")
                                            String accessConfigName,
                                            @QueryParam("networkInterface")
                                            String networkInterfaceName)
        Deletes an access config from an instance's network interface.
        Parameters:
        instance - the instance name.
        accessConfigName - the name of the access config to delete
        networkInterfaceName - network interface name.
        Returns:
        an Operation resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • getSerialPortOutput

        @Named("Instances:getSerialPortOutput")
        @GET
        @Path("/{instance}/serialPort")
        Instance.SerialPortOutput getSerialPortOutput​(@PathParam("instance")
                                                      String instance)
        Returns the specified instance's serial port output.
        Parameters:
        instance - the instance name.
        Returns:
        if successful, this method returns a SerialPortOutput containing the instance's serial output.
      • getSerialPortOutput

        @Named("Instances:getSerialPortOutput")
        @GET
        @Path("/{instance}/serialPort")
        Instance.SerialPortOutput getSerialPortOutput​(@PathParam("instance")
                                                      String instance,
                                                      @QueryParam("port")
                                                      int port)
        Returns the specified instance's serial port output.
        Parameters:
        instance - the instance name.
        Returns:
        if successful, this method returns a SerialPortOutput containing the instance's serial output.
      • reset

        @Named("Instances:reset")
        @POST
        @Path("/{instance}/reset")
        Operation reset​(@PathParam("instance")
                        String instance)
        Hard-resets the instance.
        Parameters:
        instance - the instance name
        Returns:
        an Operation resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • attachDisk

        @Named("Instances:attachDisk")
        @POST
        @Produces("application/json")
        @Path("/{instance}/attachDisk")
        Operation attachDisk​(@PathParam("instance")
                             String instance,
                             AttachDisk attachDiskOptions)
        Attaches a disk to an instance
        Parameters:
        instance - The instance name to attach to
        attachDiskOptions - The options for attaching the disk.
        Returns:
        an Operation resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • detachDisk

        @Named("Instances:detachDisk")
        @POST
        @Path("/{instance}/detachDisk")
        Operation detachDisk​(@PathParam("instance")
                             String instance,
                             @QueryParam("deviceName")
                             String deviceName)
        Detaches an attached disk from an instance
        Parameters:
        instance - The instance name to attach to
        deviceName - The device name of the disk to detach.
        Returns:
        an Operation resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • setMetadata

        @Named("Instances:setMetadata")
        @POST
        @Path("/{instance}/setMetadata")
        Operation setMetadata​(@PathParam("instance")
                              String instance,
                              Metadata metadata)
        Sets metadata for an instance using the data included in the request.

        NOTE: This *sets* metadata items on the project (vs *adding* items to metadata), if there are existing metadata that must be kept these must be fetched first and then re-sent on update.

        
            Metadata update = instanceApi.get("myInstance").metadata().clone();
            update.put("newItem","newItemValue");
            instanceApi.setMetadata("myInstance", update);
         
        Parameters:
        instance - The name of the instance
        metadata - the metadata to set
        Returns:
        an Operations resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • setTags

        @Named("Instances:setTags")
        @POST
        @Path("/{instance}/setTags")
        @Produces("application/json")
        Operation setTags​(@PathParam("instance")
                          String instance,
                          Iterable<String> items,
                          String fingerprint)
        Lists items for an instance
        Parameters:
        instance - the name of the instance
        items - A set of items
        fingerprint - The current fingerprint for the items
        Returns:
        an Operations resource. To check on the status of an operation, poll the Operations resource returned to you, and look for the status field.
      • setDiskAutoDelete

        @Named("Instances:setDiskAutoDelete")
        @POST
        @Path("/{instance}/setDiskAutoDelete")
        Operation setDiskAutoDelete​(@PathParam("instance")
                                    String instanceName,
                                    @QueryParam("deviceName")
                                    String deviceName,
                                    @QueryParam("autoDelete")
                                    boolean autoDelete)
        Sets the auto-delete flag for a disk attached to an instance
        Parameters:
        instanceName - The name of the instance
        deviceName - Disk device name to modify.
        autoDelete - Whether to auto-delete the disk when the instance is deleted
      • setScheduling

        @Named("Instances:setScheduling")
        @POST
        @Path("/{instance}/setScheduling")
        Operation setScheduling​(@PathParam("instance")
                                String instanceName,
                                Instance.Scheduling.OnHostMaintenance onHostMaintenance,
                                boolean automaticRestart,
                                boolean preemptible)
        Sets an instance's scheduling options.
        Parameters:
        instanceName - The name of the instance
        onHostMaintenance - either MIGRATE or TERMINATE the default is MIGRATE (Live Migration).
        automaticRestart - Defines whether the Instance should be automatically restarted when it is terminated by Compute Engine (not terminated by user). Used when onHostMaintenance is set to TERMINATE.
        preemptible - Defines whether the Instance should be launched as spot instance
        Returns:
        See Also:
      • start

        @Named("Instances:start")
        @POST
        @Path("/{instance}/start")
        @Produces("application/json")
        Operation start​(@PathParam("instance")
                        String instance)
        This method starts an instance that was stopped using the using the stop(String) method.
        Parameters:
        instance - - name of the instance to be started
      • stop

        @Named("Instances:stop")
        @POST
        @Path("/{instance}/stop")
        @Produces("application/json")
        Operation stop​(@PathParam("instance")
                       String instance)
        This method stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur per-minute, virtual machine usage charges while they are stopped, but any resources that the virtual machine is using, such as persistent disks and static IP addresses,will continue to be charged until they are deleted.
        Parameters:
        instance -
        Returns:
      • listPage

        @Named("Instances:list")
        @GET
        ListPage<Instance> listPage​(@Nullable @QueryParam("pageToken")
                                    String pageToken,
                                    ListOptions listOptions)
        Retrieves the list of instance resources available to the specified project. By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not been set.
        Parameters:
        pageToken - marks the beginning of the next list page
        listOptions - listing options
        Returns:
        a page of the list