use of com.microsoft.graph.options.Option in project msgraph-sdk-java by microsoftgraph.
the class BaseCollectionRequestTests method testFunctionAndQueryParameters.
@Test
public void testFunctionAndQueryParameters() {
final Option f1 = new FunctionOption("f1", "fun1");
final Option f2 = new FunctionOption("f2", null);
final Option q1 = new QueryOption("q1", "option1 ");
final Option q2 = new QueryOption("q2", "option2");
final BaseCollectionRequest<String, String> request = new BaseCollectionRequest<String, String>("https://a.b.c", null, Arrays.asList(f1, f2, q1, q2), null, null) {
};
assertEquals("https://a.b.c(f1='fun1',f2=null)?q1=option1+&q2=option2", request.getRequestUrl().toString());
assertEquals(5, request.getOptions().size());
}
use of com.microsoft.graph.options.Option in project msgraph-sdk-java by microsoftgraph.
the class BaseRequestTests method testFunctionAndQueryParameters.
@Test
public void testFunctionAndQueryParameters() {
final Option f1 = new FunctionOption("f1", "fun1");
final Option f2 = new FunctionOption("f2", null);
final Option q1 = new QueryOption("q1", "option1 ");
final Option q2 = new QueryOption("q2", "option2");
final BaseRequest request = new BaseRequest("https://a.b.c", null, Arrays.asList(f1, f2, q1, q2), null) {
};
assertEquals("https://a.b.c(f1='fun1',f2=null)?q1=option1+&q2=option2", request.getRequestUrl().toString());
assertEquals(5, request.getOptions().size());
}
use of com.microsoft.graph.options.Option in project android-java-snippets-sample by microsoftgraph.
the class MeSnippets method getMeSnippets.
static MeSnippets[] getMeSnippets() {
return new MeSnippets[] { // Marker element
new MeSnippets(null) {
@Override
public void request(ICallback callback) {
// Not implemented
}
}, /* Get information about signed in user
* HTTP GET https://graph.microsoft.com/{version}/me
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/user_get
*/
new MeSnippets<JsonObject>(get_me) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getMe().buildRequest().get(new ICallback<User>() {
@Override
public void success(User user) {
callback.success(user.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /* Get responsibilities of signed in user
* HTTP GET https://graph.microsoft.com/{version}/me?$select=AboutMe,Responsibilities,Tags
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<JsonObject>(get_me_responsibilities) {
@Override
public void request(final ICallback<JsonObject> callback) {
final List<Option> options = new LinkedList<>();
options.add(new QueryOption("$select", "AboutMe,Responsibilities,Tags"));
mGraphServiceClient.getMe().buildRequest(options).get(new ICallback<User>() {
@Override
public void success(User user) {
callback.success(user.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /* Get the user's manager
* HTTP GET https://graph.microsoft.com/{version}/me/manager
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<JsonObject>(get_me_manager) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getMe().getManager().buildRequest().get(new ICallback<DirectoryObject>() {
@Override
public void success(DirectoryObject directoryObject) {
callback.success(directoryObject.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /* Get the user's direct reports
* HTTP GET https://graph.microsoft.com/{version}/me/directReports
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<JsonObject>(get_me_direct_reports) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getMe().getDirectReports().buildRequest().get(new ICallback<IDirectoryObjectCollectionWithReferencesPage>() {
@Override
public void success(IDirectoryObjectCollectionWithReferencesPage iDirectoryObjectCollectionWithReferencesPage) {
callback.success(iDirectoryObjectCollectionWithReferencesPage.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /* Get the group membership of the user
* HTTP GET https://graph.microsoft.com/{version}/me/memberOf
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<JsonObject>(get_me_group_membership) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getMe().getMemberOf().buildRequest().get(new ICallback<IDirectoryObjectCollectionWithReferencesPage>() {
@Override
public void success(IDirectoryObjectCollectionWithReferencesPage iDirectoryObjectCollectionWithReferencesPage) {
callback.success(iDirectoryObjectCollectionWithReferencesPage.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /* Get the photo of the user
* HTTP GET https://graph.microsoft.com/{version}/me/userPhoto
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<JsonObject>(get_me_photo) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getMe().getPhoto().buildRequest().get(new ICallback<ProfilePhoto>() {
@Override
public void success(ProfilePhoto profilePhoto) {
callback.success(profilePhoto.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
} };
}
use of com.microsoft.graph.options.Option in project android-java-snippets-sample by microsoftgraph.
the class UsersSnippets method getUsersSnippets.
static UsersSnippets[] getUsersSnippets() {
return new UsersSnippets[] { // Marker element
new UsersSnippets(null) {
@Override
public void request(ICallback callback) {
// Not implemented
}
}, /*
* Gets all of the users in your tenant\'s directory.
* HTTP GET https://graph.microsoft.com/{version}/myOrganization/users
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/user_list
*/
new UsersSnippets<JsonObject>(get_organization_users) {
@Override
public void request(final ICallback<JsonObject> callback) {
mGraphServiceClient.getUsers().buildRequest().get(new ICallback<IUserCollectionPage>() {
@Override
public void success(IUserCollectionPage iUserCollectionPage) {
callback.success(iUserCollectionPage.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /*
* Gets all of the users in your tenant's directory who are from the United States, using $filter.
* HTTP GET https://graph.microsoft.com/{version}/myOrganization/users?$filter=country eq \'United States\'
* @see http://graph.microsoft.io/docs/overview/query_parameters
*/
new UsersSnippets<JsonObject>(get_organization_filtered_users) {
@Override
public void request(final ICallback<JsonObject> callback) {
final List<Option> options = new LinkedList<>();
options.add(new QueryOption("$filter", "country eq 'United States'"));
mGraphServiceClient.getUsers().buildRequest(options).get(new ICallback<IUserCollectionPage>() {
@Override
public void success(IUserCollectionPage iUserCollectionPage) {
callback.success(iUserCollectionPage.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
}, /*
* Adds a new user to the tenant's directory
* HTTP POST https://graph.microsoft.com/{version}/myOrganization/users
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/user_post_users
*/
new UsersSnippets<JsonObject>(insert_organization_user) {
@Override
public void request(final ICallback<JsonObject> callback) {
// Use a random UUID for the user name
String randomUserName = UUID.randomUUID().toString();
// create the user
User user = new User();
user.accountEnabled = true;
user.displayName = "SAMPLE " + randomUserName;
user.mailNickname = randomUserName;
// get the tenant from preferences
SharedPreferences prefs = SharedPrefsUtil.getSharedPreferences();
String tenant = prefs.getString(PREF_USER_TENANT, "");
user.userPrincipalName = randomUserName + "@" + tenant;
// initialize a password & say whether or not the user must change it
PasswordProfile password = new PasswordProfile();
password.password = UUID.randomUUID().toString().substring(0, 16);
password.forceChangePasswordNextSignIn = false;
user.passwordProfile = password;
mGraphServiceClient.getUsers().buildRequest().post(user, new ICallback<User>() {
@Override
public void success(User user) {
callback.success(user.getRawObject());
}
@Override
public void failure(ClientException ex) {
callback.failure(ex);
}
});
}
} };
}
use of com.microsoft.graph.options.Option in project msgraph-sdk-java by microsoftgraph.
the class SharePointTests method testSearch.
@Test
public void testSearch() {
List<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new QueryOption("search", "Contoso"));
ISiteCollectionPage sites = testBase.graphClient.sites().buildRequest(requestOptions).get();
assertNotNull(sites);
}
Aggregations