Class List Method List File List

# Class: Com::Vmware::Content::Library::Item::Updatesession::File

Inherits:
  VAPI::Bindings::VapiService
  - Object
  - VAPI::Bindings::VapiService
  - Com::Vmware::Content::Library::Item::Updatesession::File
  show all
Defined in:
  /build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb

## Overview

The ``Com::Vmware::Content::Library::Item::Updatesession::File`` class provides methods for accessing files within an update session.

     After an update session is created against a library item, the  ``Com::Vmware::Content::Library::Item::Updatesession::File``   class  can be used to make changes to the underlying library item metadata as well as the content of the files. The following changes can be made:

      * deleting an existing file within the library item. This deletes both the metadata and the content.
       * updating an existing file with new content.
       * adding a new file to the library item.

     The above changes are not applied or visible until the session is completed. See   :class:`Com::Vmware::Content::Library::Item::UpdateSession`  .

## Defined Under Namespace

Classes: AddSpec, Info, SourceType, ValidationError, ValidationResult

## Instance Method Summary (collapse)

- - (Com::Vmware::Content::Library::Item::Updatesession::File::Info) add(update_session_id, file_spec)

  Requests file content to be changed (either created, or updated).

- - (Com::Vmware::Content::Library::Item::Updatesession::File::Info) get(update_session_id, file_name)

  Retrieves information about a specific file in the snapshot of the library item at the time when the update session was created.

- - (File) initialize(config) constructor

  Constructs a new instance.

- - (Array<Com::Vmware::Content::Library::Item::Updatesession::File::Info>) list(update_session_id)

  Lists all files in the library item associated with the update session.

- - (Void) remove(update_session_id, file_name)

  Requests a file to be removed.

- - (Com::Vmware::Content::Library::Item::Updatesession::File::ValidationResult) validate(update_session_id)

  Validates the files in the update session with the referenced identifier and ensures all necessary files are received.

## Constructor Details

### - (`File`) initialize(config)

Constructs a new instance.

Parameters:

- config (`VAPI::Bindings::StubConfig`) —

  A hash with the api provider details.

    126
    127
    128
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb', line 126

    def initialize(config)
        super(config, @@service_info)
    end

## Instance Method Details

### - (`Com::Vmware::Content::Library::Item::Updatesession::File::Info`) add(update_session_id, file_spec)

Requests file content to be changed (either created, or updated). Depending on the source type of the file, this method will either return an upload endpoint where the client can push the content, or the server will pull from the provided source endpoint. If a file with the same name already exists in this session, this method will be used to update the content of the existing file.

     When importing a file directly from storage, where the source endpoint is a file or datastore URI, you will need to have the ContentLibrary.ReadStorage privilege on the library item. If the file is located in the same directory as the library storage backing folder, the server will move the file instead of copying it, thereby allowing instantaneous import of files for efficient backup and restore scenarios. In all other cases, a copy is performed rather than a move.

Parameters:

- update_session_id (`String`) —

  Identifier of the update session to be modified.

- file_spec (`Com::Vmware::Content::Library::Item::Updatesession::File::AddSpec`) —

  Specification for the file that needs to be added or updated. This includes whether the client wants to push the content or have the server pull it.

Returns:

- (`Com::Vmware::Content::Library::Item::Updatesession::File::Info`) —

  An :class:`Com::Vmware::Content::Library::Item::Updatesession::File::Info` class containing upload links as well as server side state tracking the transfer of the file.

Raises:

- (`Com::Vmware::Vapi::Std::Errors::InvalidArgument`) —

  if the ``file_spec`` is invalid.

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the update session doesn’t exist.

- (`Com::Vmware::Vapi::Std::Errors::Unauthorized`) —

  if the caller doesn’t have ContentLibrary.ReadStorage privilege on the library item of the update session and source type :attr:`Com::Vmware::Content::Library::Item::Updatesession::File::SourceType.PULL` is requested for a file or datastore source endpoint (that is, not HTTP or HTTPs based endpoint).

    164
    165
    166
    167
    168
    169
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb', line 164

    def add(update_session_id, file_spec)
        invoke_with_info(@@add_info, {
            'update_session_id' => update_session_id,
            'file_spec' => file_spec,
        })
    end

### - (`Com::Vmware::Content::Library::Item::Updatesession::File::Info`) get(update_session_id, file_name)

Retrieves information about a specific file in the snapshot of the library item at the time when the update session was created.

Parameters:

- update_session_id (`String`) —

  Identifier of the update session.

- file_name (`String`) —

  Name of the file.

Returns:

- (`Com::Vmware::Content::Library::Item::Updatesession::File::Info`) —

  Information about the file.

Raises:

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the update session doesn’t exist.

- (`Com::Vmware::Vapi::Std::Errors::InvalidArgument`) —

  if the file doesn’t exist in the library item associated with the update session.

    218
    219
    220
    221
    222
    223
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb', line 218

    def get(update_session_id, file_name)
        invoke_with_info(@@get_info, {
            'update_session_id' => update_session_id,
            'file_name' => file_name,
        })
    end

### - (`Array<Com::Vmware::Content::Library::Item::Updatesession::File::Info>`) list(update_session_id)

Lists all files in the library item associated with the update session.

Parameters:

- update_session_id (`String`) —

  Identifier of the update session.

Returns:

- (`Array<Com::Vmware::Content::Library::Item::Updatesession::File::Info>`) —

  The list of the files in the library item associated with the update session. This list may be empty if the caller has removed all the files as part of this session (in which case completing the update session will result in an empty library item).

Raises:

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the update session doesn’t exist.

    199
    200
    201
    202
    203
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb', line 199

    def list(update_session_id)
        invoke_with_info(@@list_info, {
            'update_session_id' => update_session_id,
        })
    end

### - (`Void`) remove(update_session_id, file_name)

Requests a file to be removed. The file will only be effectively removed when the update session is completed.

Parameters:

- update_session_id (`String`) —

  Identifier of the update session.

- file_name (`String`) —

  Name of the file to be removed.

Returns:

- (`Void`)

Raises:

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if the update session doesn’t exist.

- (`Com::Vmware::Vapi::Std::Errors::InvalidArgument`) —

  if the file doesn’t exist in the library item associated with the update session.

    183
    184
    185
    186
    187
    188
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb', line 183

    def remove(update_session_id, file_name)
        invoke_with_info(@@remove_info, {
            'update_session_id' => update_session_id,
            'file_name' => file_name,
        })
    end

### - (`Com::Vmware::Content::Library::Item::Updatesession::File::ValidationResult`) validate(update_session_id)

Validates the files in the update session with the referenced identifier and ensures all necessary files are received. In the case where a file is missing, this method will return its name in the :attr:`Com::Vmware::Content::Library::Item::Updatesession::File::ValidationResult.missing_files` set. The user can add the missing files and try re-validating. For other type of errors, :attr:`Com::Vmware::Content::Library::Item::Updatesession::File::ValidationResult.invalid_files` will contain the list of invalid files.

Parameters:

- update_session_id (`String`) —

  Identifier of the update session to validate.

Returns:

- (`Com::Vmware::Content::Library::Item::Updatesession::File::ValidationResult`) —

  A validation result containing missing files or invalid files and the reason why they are invalid.

Raises:

- (`Com::Vmware::Vapi::Std::Errors::NotFound`) —

  if no update session with the given identifier exists.

- (`Com::Vmware::Vapi::Std::Errors::NotAllowedInCurrentState`) —

  if the update session is not in the :attr:`Com::Vmware::Content::Library::Item::UpdateSessionModel::State.ACTIVE` state, or if some of the files that will be uploaded by the client aren’t received correctly.

    141
    142
    143
    144
    145
    # File '/build/mts/release/bora-4571906/build/sdk/aggregated-bindings/ruby/com/vmware/content/library/item/updatesession.rb', line 141

    def validate(update_session_id)
        invoke_with_info(@@validate_info, {
            'update_session_id' => update_session_id,
        })
    end