Skip to content

Commit

Permalink
Merge pull request #2 from continuumsecurity/feature/CON-462
Browse files Browse the repository at this point in the history
[CON-462] Adding client example
  • Loading branch information
areyes-cs authored Apr 14, 2020
2 parents 26d9859 + b2515f9 commit 6b95792
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
target/classes
target/generated-sources
target/maven-archiver
target/maven-status
target
.gitignore
.git
.idea
54 changes: 54 additions & 0 deletions IriusRiskClientExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2012-2020 Continuum Security. All rights reserved
*/
package com.iriusrisk.client;

import com.iriusrisk.ApiException;
import com.iriusrisk.api.ProductsApi;
import com.iriusrisk.model.CreateProduct;
import com.iriusrisk.model.ProductShort;

import java.io.File;
import java.util.List;

/**
* This is an example of how to use IriusRisk Client Lib to perform some actions
*/
public class IriusRiskClient {
public static void main(String[] args) {

System.out.println("New IriusRisk instance");
ProductsApi apiInstance = new ProductsApi();
String apiToken = "<api-token>";

try {

// Get list of products
List<ProductShort> rs = apiInstance.productsGet(apiToken);
System.out.println("Product List: " + rs);

// Create new product
CreateProduct createProduct = new CreateProduct();
createProduct.setName("name-prod-api-test");
createProduct.setDesc("desc-prod-api-test");
createProduct.setRef("ref-prod-api-test");
ProductShort newProduct = apiInstance.productsPost(apiToken, createProduct);

System.out.println("New Product: " + newProduct.toString());

// Import from XML template
// Note: import process may be slow, so this should be launched asynchronously
File file = new File("</path/to/file.xml>");
ProductShort p = apiInstance.productsUploadPost(apiToken, "reference", "NewProduct", file, "STANDARD");
System.out.println("Product Imported");


} catch (ApiException e) {
System.err.println("Exception when calling AuthorizationApi#rolesPost");
e.printStackTrace();
}

}


}
1 change: 0 additions & 1 deletion iriusrisk.yaml

This file was deleted.

0 comments on commit 6b95792

Please sign in to comment.