Download Citrix Administration API Code Sample

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Citrix Administration API Code Sample
This sample generates a series of Administration REST API calls for a GoTo
Administration account. The intention is to quickly show a sequence of calls, the
exact syntax and the data relationships among the calls.
In this sample, the user and license handling is demonstrated, for other use cases
see the documentation at https://developer.citrixonline.com/code-samples.
Sample application requirements





Citrix GoTo Administration account (this code will not operate properly on nonadmin GoTo accounts)
Java SDK v1.6 +
Integrated development environment (IDE), e.g., Eclipse, NetBeans, IntelliJ
IDEA, Codenvy, etc.
Maven Project Management tool installed in your IDE
Sample application source extracted into tmp/src, download it here:
https://developer.citrixonline.com/code-samples#AdministrationAPISample
Running the sample application
1. Obtain a client_id (aka Consumer Key) from https://developer.citrixonline.com.
See https://developer.citrixonline.com/getting-started-0 for instructions. The
developer application can be for GoToMeeting, GoToTraining or GoToWebinar.
2. Modify and save src/main/resources/admin.properties with your Citrix Admin
account email and password, and the developer application client_id.
3. In your IDE, load the sample application package (/src).
4. In the package, right-click ClientApplication.java in com.citrix.admin located in
/src/main/java and select Run As… Java Application.
Example from Eclipse IDE
The application is executed. It may take a few minutes to complete.
NOTE: If you need to modify the admin.properties file and re-run the sample code,
you will need to use your IDE’s capabilities to empty the code buffers. You will need
to set the project to not Build Automatically, run a Clean or Empty command, and
then set the project to Build Automatically again. You can then re-run the code with
the modified values.
The executed calls step by step
All calls are logged to your IDE console.
1. The access token is created by using Direct Login.
(https://developer.citrixonline.com/page/direct-login)
2. The Get Me call is used to retrieve the user information.
(https://developer.citrixonline.com/get-me)
3. The accountKey, retrieved from the Get Me response, is used to call Get
Account. (https://developer.citrixonline.com/get-account)
The accountKey is used in all the remaining calls.
4. A new user is created with the call Create User.
(https://developer.citrixonline.com/create-user)
5. The new user is modified with an Update User call.
(https://developer.citrixonline.com/update-user)
6. The full user data is shown with a Get User call.
(https://developer.citrixonline.com/get-user)
7. The call Get Licenses is made to get the licenses of this user.
(https://developer.citrixonline.com/get-licenses)
8. The user licenses are updated with License Users.
(https://developer.citrixonline.com/license-users)
9. The user is checked using the call Get User.
(https://developer.citrixonline.com/get-user)
10. The licenses are revoked using Unlicense Users.
(https://developer.citrixonline.com/unlicense-users)
11. Now the user is deleted with the call Delete Users.
(https://developer.citrixonline.com/delete-users)
12. All users are retrieved using the Get All Users call.
(https://developer.citrixonline.com/get-all-users)
© 2014 Citrix Online, LLC. All rights reserved. Citrix, GoToAssist, GoToMeeting, GoToMyPC, GoToTraining,
GoToWebinar, Podio and Sharefile are trademarks of Citrix Systems, Inc., or a subsidiary thereof, and are or
may be registered in the U.S. Patent and Trademark Office and other countries. All other trademarks are the
property of their respective owners.
Code description
ClientApplication.java: The main file for the application.
common
Configuration.java: Here the property file is read and some path constants are set
dao
AbstractDAO.java: The base class of the following classes (includes Direct Login)
AdminDAO.java: The calls Get Me and Get Account
LicenseDAO.java: The calls Get Licenses, License Users and Unlicense Users
UserDAO.java: The calls Create User, Get User, Update User, Delete Users,
Provision User by Product and Get All Users
interceptor
AdminInterceptor.java: This class intercepts each call to the Admin API and
performs common actions (like logging) for each call
model
These classes are for storing the API responses as objects.
AbstractModel.java: The base class of the following classes
Account.java: The account class
EmailTemplate.java: The email template class
License.java: The license class
User.java: The user class
service
AdminService.java: Business facade to service application requests to the
administration service
AdminServiceImpl.java: Implementation of the service application requests to the
administration service
util
The following classes are helper classes for data structure conversion from the
JSON responses.
LicensesResult.java: Helper for license calls
UserKeyEmail.java: Helper for user emails and keys
UsersDTO.java: Helper for users
UsersResult.java: A user list
© 2014 Citrix Online, LLC. All rights reserved. Citrix, GoToAssist, GoToMeeting, GoToMyPC, GoToTraining,
GoToWebinar, Podio and Sharefile are trademarks of Citrix Systems, Inc., or a subsidiary thereof, and are or
may be registered in the U.S. Patent and Trademark Office and other countries. All other trademarks are the
property of their respective owners.