com.vmware.vcloud.sdk
Class Media

java.lang.Object
  extended by com.vmware.vcloud.sdk.VcloudResource<T>
      extended by com.vmware.vcloud.sdk.VcloudEntity<com.vmware.vcloud.api.rest.schema.MediaType>
          extended by com.vmware.vcloud.sdk.Media

public class Media
extends VcloudEntity<com.vmware.vcloud.api.rest.schema.MediaType>

Helper class to access the Media Resource in vCloud API.

See Also:
MediaType

Constructor Summary
Media(VcloudClient client, com.vmware.vcloud.api.rest.schema.MediaType mediaResource_v1_5)
          Constructor to create the Media.
 
Method Summary
 Task delete()
          Delete Media .
static Task delete(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
          Delete Media .
 Task deleteMedia()
          1.
static Task deleteMedia(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
          1.
 void downloadMedia(String downloadLocation)
          Download the media as an ISO or Floppy file at the specified location.
 void downloadMedia(String downloadLocation, String mediaName)
          Download the media as an ISO or Floppy file at the specified location with the specified name.
 Task enableDownload()
          Enable download for the media
static Task enableDownload(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
          Enable download for the media
 com.vmware.vcloud.api.rest.schema.ReferenceType getCatalogItemReference()
          Returns the CatalogItem reference which contains this media.
static Media getMediaById(VcloudClient client, String vCloudId)
          Get Media helper using the vCloud ID
static Media getMediaByReference(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
          Get Media for the given media reference
 com.vmware.vcloud.api.rest.schema.ReferenceType getOwner()
          Returns the owner of the media.
 Set<String> getUploadedFileNames()
          Get the uploaded file names for thie media
 Set<String> getUploadFileNames()
          Get the upload file names for this Media.
 com.vmware.vcloud.api.rest.schema.ReferenceType getVdcReference()
          Returns the Parent Vdc ReferenceType.
 boolean isPartOfCatalogItem()
          Returns true if VappTemplate is in Catalog, otherwise false.
 HashMap<String,com.vmware.vcloud.api.rest.schema.FileType> monitorUpload()
          Monitor the file upload status.
 Task updateMedia(com.vmware.vcloud.api.rest.schema.MediaType mediaType)
          Updates name and description of Media .Any other attributes/elements will be ignored.
 void uploadFile(String fileName, InputStream is, long size)
          Upload the Media file.
 void uploadFile(String fileName, InputStream is, long startByte, long endByte)
          Partial Upload the Media file.
 
Methods inherited from class com.vmware.vcloud.sdk.VcloudEntity
getMetadata, getReference, getTasks
 
Methods inherited from class com.vmware.vcloud.sdk.VcloudResource
getResource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Media

public Media(VcloudClient client,
             com.vmware.vcloud.api.rest.schema.MediaType mediaResource_v1_5)
Constructor to create the Media. The Media object will be returned.

Parameters:
client - The VcloudClient used to communicate with the vCloud
Method Detail

getMediaByReference

public static Media getMediaByReference(VcloudClient client,
                                        com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
                                 throws VCloudException
Get Media for the given media reference

Parameters:
client -
mediaRef -
Returns:
Media
Throws:
VCloudException

getMediaById

public static Media getMediaById(VcloudClient client,
                                 String vCloudId)
                          throws VCloudException
Get Media helper using the vCloud ID

Parameters:
client - VcloudClient
vCloudId - format - The vCloud ID is of the form: "urn:vcloud:type:uuid". For example: "urn:vcloud:media:d9d976ba-e0ec-4682-a67d-380af49b54e1". String
Returns:
Media
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

updateMedia

public Task updateMedia(com.vmware.vcloud.api.rest.schema.MediaType mediaType)
                 throws VCloudException
Updates name and description of Media .Any other attributes/elements will be ignored.

Parameters:
mediaType - MediaType
Returns:
Task
Throws:
VCloudException

delete

public Task delete()
            throws VCloudException
Delete Media . This is long running operation and returns the Task

Returns:
Task Task
Throws:
VCloudException

delete

public static Task delete(VcloudClient client,
                          com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
                   throws VCloudException
Delete Media . This is long running operation and returns the Task

Parameters:
client - vCloud Client VcloudClient
mediaRef - Media Ref
Returns:
Task Task
Throws:
VCloudException

deleteMedia

public Task deleteMedia()
                 throws VCloudException
1. Deletes media and its catalog item, if the media is attached to a catalog item. 2. Deletes media alone, if the media is not attached to any catalog item. This is long running operation and returns the Task.

Returns:
Task
Throws:
VCloudException
Since:
API 1.5, SDK 5.1

deleteMedia

public static Task deleteMedia(VcloudClient client,
                               com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
                        throws VCloudException
1. Deletes media and its catalog item, if the media is attached to a catalog item. 2. Deletes media alone, if the media is not attached to any catalog item. This is long running operation and returns the Task.

Parameters:
client - VcloudClient
mediaRef -
Returns:
Task
Throws:
VCloudException
Since:
API 1.5, SDK 5.1

getUploadFileNames

public Set<String> getUploadFileNames()
Get the upload file names for this Media.

Returns:
Set

getUploadedFileNames

public Set<String> getUploadedFileNames()
Get the uploaded file names for thie media

Returns:
Set

uploadFile

public void uploadFile(String fileName,
                       InputStream is,
                       long size)
                throws VCloudException
Upload the Media file. This can be ISO or Floppy file and must be present in the Media file Map.

Parameters:
fileName - Media File name
is - Input stream for the file contents
size - The size of the media file to upload
Throws:
VCloudException

uploadFile

public void uploadFile(String fileName,
                       InputStream is,
                       long startByte,
                       long endByte)
                throws VCloudException
Partial Upload the Media file. This can be ISO or Floppy file and must be present Media file Map.

Parameters:
fileName - Media File name
is - Input stream for the file contents
startByte - starting byte
endByte - ending byte
Throws:
VCloudException

monitorUpload

public HashMap<String,com.vmware.vcloud.api.rest.schema.FileType> monitorUpload()
                                                                         throws VCloudException
Monitor the file upload status. The returned hash map contains file name and its filetype (which contains more information like totalBytes, bytesTransferred etc.). Successice invocations of this method would result in an updated hashmap.

Returns:
HashMap<String, FileType>
Throws:
VCloudException

getCatalogItemReference

public com.vmware.vcloud.api.rest.schema.ReferenceType getCatalogItemReference()
                                                                        throws VCloudException
Returns the CatalogItem reference which contains this media.

Returns:
ReferenceType
Throws:
VCloudException

getVdcReference

public com.vmware.vcloud.api.rest.schema.ReferenceType getVdcReference()
                                                                throws VCloudException
Returns the Parent Vdc ReferenceType.

Returns:
ReferenceType
Throws:
VCloudException

getOwner

public com.vmware.vcloud.api.rest.schema.ReferenceType getOwner()
                                                         throws VCloudException
Returns the owner of the media.

Returns:
ReferenceType
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

isPartOfCatalogItem

public boolean isPartOfCatalogItem()
                            throws VCloudException
Returns true if VappTemplate is in Catalog, otherwise false.

Returns:
Boolean
Throws:
VCloudException
Since:
API 1.5, SDK 5.1

enableDownload

public Task enableDownload()
                    throws VCloudException
Enable download for the media

Returns:
Task
Throws:
VCloudException
Since:
API 5.5, SDK 5.5

enableDownload

public static Task enableDownload(VcloudClient client,
                                  com.vmware.vcloud.api.rest.schema.ReferenceType mediaRef)
                           throws VCloudException
Enable download for the media

Parameters:
client - VcloudClient
mediaRef - ReferenceType
Returns:
Task
Throws:
VCloudException
Since:
API 5.5, SDK 5.5

downloadMedia

public void downloadMedia(String downloadLocation)
                   throws VCloudException
Download the media as an ISO or Floppy file at the specified location. Before downloading make sure the media is enabled for download. The downloaded media file name will be the same as the current media file name in execution.

Parameters:
downloadLocation - String
Throws:
VCloudException
Since:
API 5.5, SDK 5.5
See Also:
media#enableDownload()

downloadMedia

public void downloadMedia(String downloadLocation,
                          String mediaName)
                   throws VCloudException
Download the media as an ISO or Floppy file at the specified location with the specified name. Before downloading make sure the media is enabled for download.

Parameters:
downloadLocation - String
mediaName - String
Throws:
VCloudException
Since:
API 5.5, SDK 5.5
See Also:
media#enableDownload()


Copyright © 2016. All Rights Reserved.