<commit_before>---
title: Java-sdk
category: sdk
authors: adahms, <NAME>, moti
wiki_category: SDK
wiki_title: Java-sdk
wiki_revision_count: 73
wiki_last_updated: 2014-07-24
---

# Java-sdk

The oVirt Java-SDK is an automatically generated software development kit for the oVirt engine API. This software development kit allows you to develop Java-based applications for automating a variety of complex administrative tasks in oVirt.

__TOC__

## Concepts

*   Auto-Generated
*   Complete protocol abstraction.
*   Full compliance with the oVirt api architecture.
*   Self descriptive.
*   Intuitive and easy to use.

## IDE Examples

### Creating the proxy:

------------------------------------------------------------------------

![](0-1jdk.jpg "0-1jdk.jpg")

#### Authenticating using user name and password:

![](0-1-1jdk.jpg "0-1-1jdk.jpg")

#### Authenticating using sessionid:

![](0-1-2jdk.jpg "0-1-2jdk.jpg")

### Listing all collections:

------------------------------------------------------------------------

![](1jsdk.jpg "1jsdk.jpg")

### Listing the methods of a collection:

------------------------------------------------------------------------

![](2jdk.jpg "2jdk.jpg")

### Querying a collection using a oVirt search engine query and custom constraints:

------------------------------------------------------------------------

![](3jdk.jpg "3jdk.jpg")

### Accessing resource methods and properties:

------------------------------------------------------------------------

![](4jdk.jpg "4jdk.jpg")

### Creating a resource:

------------------------------------------------------------------------

![](5jdk.jpg "5jdk.jpg")

### Accessing resource properties and sub-collections:

------------------------------------------------------------------------

![](6jdk.jpg "6jdk.jpg")

### Accessing sub-collection methods:

------------------------------------------------------------------------

![](7jdk.jpg "7jdk.jpg")

### Querying a sub-collection using custom constraints:

------------------------------------------------------------------------

TBD

### Retrieving a sub-collection resource:

------------------------------------------------------------------------

![](8jdk.jpg "8jdk.jpg")

### Accessing sub-collection resource properties and methods

------------------------------------------------------------------------

![](9jdk.jpg "9jdk.jpg")

## Examples

### create proxy

         // #1 - import
         import org.ovirt.engine.sdk.Api;

         // #2 - create proxy
         Api api = new Api("`[`http://localhost:8080/api`](http://localhost:8080/api)`", "user@domain", "password");

### list entities

         // #1 - list resources
         List`<VM>` vms = api.getVMs().list();

### update resource

         // #1 - fetch resource
         VM vm = api.getVMs().get("test");

         // #2 - modify it
         vm.setDescription("java_sdk");

         // #3 - update it
         VM newVM = vm.update();
<commit_msg>Accessing sub-collection resource properties and methods<commit_after>---
title: Java-sdk
category: sdk
authors: adahms, <NAME>, moti
wiki_category: SDK
wiki_title: Java-sdk
wiki_revision_count: 73
wiki_last_updated: 2014-07-24
---

# Java-sdk

The oVirt Java-SDK is an automatically generated software development kit for the oVirt engine API. This software development kit allows you to develop Java-based applications for automating a variety of complex administrative tasks in oVirt.

__TOC__

## Concepts

*   Auto-Generated
*   Complete protocol abstraction.
*   Full compliance with the oVirt api architecture.
*   Self descriptive.
*   Intuitive and easy to use.

## IDE Examples

### Creating the proxy:

------------------------------------------------------------------------

![](0-1jdk.jpg "0-1jdk.jpg")

#### Authenticating using user name and password:

![](0-1-1jdk.jpg "0-1-1jdk.jpg")

#### Authenticating using sessionid:

![](0-1-2jdk.jpg "0-1-2jdk.jpg")

### Listing all collections:

------------------------------------------------------------------------

![](1jsdk.jpg "1jsdk.jpg")

### Listing the methods of a collection:

------------------------------------------------------------------------

![](2jdk.jpg "2jdk.jpg")

### Querying a collection using a oVirt search engine query and custom constraints:

------------------------------------------------------------------------

![](3jdk.jpg "3jdk.jpg")

### Accessing resource methods and properties:

------------------------------------------------------------------------

![](4jdk.jpg "4jdk.jpg")

### Creating a resource:

------------------------------------------------------------------------

![](5jdk.jpg "5jdk.jpg")

### Accessing resource properties and sub-collections:

------------------------------------------------------------------------

![](6jdk.jpg "6jdk.jpg")

### Accessing sub-collection methods:

------------------------------------------------------------------------

![](7jdk.jpg "7jdk.jpg")

### Querying a sub-collection using custom constraints:

------------------------------------------------------------------------

TBD

### Retrieving a sub-collection resource:

------------------------------------------------------------------------

![](8jdk.jpg "8jdk.jpg")

### Accessing sub-collection resource properties and methods:

------------------------------------------------------------------------

![](9jdk.jpg "9jdk.jpg")

## Examples

### create proxy

         // #1 - import
         import org.ovirt.engine.sdk.Api;

         // #2 - create proxy
         Api api = new Api("`[`http://localhost:8080/api`](http://localhost:8080/api)`", "user@domain", "password");

### list entities

         // #1 - list resources
         List`<VM>` vms = api.getVMs().list();

### update resource

         // #1 - fetch resource
         VM vm = api.getVMs().get("test");

         // #2 - modify it
         vm.setDescription("java_sdk");

         // #3 - update it
         VM newVM = vm.update();

{'fraction_non_alphanumeric': 0.3732041430003341, 'fraction_numerical': 0.01937854994988306, 'mean_word_length': 1.268662372110648, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5772040', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1613, 'n_words': 419}