Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR graphrbac/data-plane] Add service principals by app id microsoft.graph rbac #3140

Merged
merged 4 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ApplicationCreateParameters extends ApplicationBase {
/**
* A collection of URIs for the application.
*/
@JsonProperty(value = "identifierUris", required = true)
@JsonProperty(value = "identifierUris")
private List<String> identifierUris;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ interface ApplicationsService {
@PATCH("{tenantID}/applications/{applicationObjectId}/passwordCredentials")
Observable<Response<ResponseBody>> updatePasswordCredentials(@Path("applicationObjectId") String applicationObjectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body PasswordCredentialsUpdateParameters parameters, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.graphrbac.Applications getServicePrincipalsIdByAppId" })
@GET("{tenantID}/servicePrincipalsByAppId/{applicationID}/objectId")
Observable<Response<ResponseBody>> getServicePrincipalsIdByAppId(@Path("tenantID") String tenantID, @Path("applicationID") String applicationID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.graphrbac.Applications listNext" })
@GET
Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
Expand Down Expand Up @@ -1296,6 +1300,85 @@ private ServiceResponse<Void> updatePasswordCredentialsDelegate(Response<Respons
.build(response);
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @param applicationID The application ID.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws GraphErrorException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ServicePrincipalObjectResultInner object if successful.
*/
public ServicePrincipalObjectResultInner getServicePrincipalsIdByAppId(String applicationID) {
return getServicePrincipalsIdByAppIdWithServiceResponseAsync(applicationID).toBlocking().single().body();
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @param applicationID The application ID.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<ServicePrincipalObjectResultInner> getServicePrincipalsIdByAppIdAsync(String applicationID, final ServiceCallback<ServicePrincipalObjectResultInner> serviceCallback) {
return ServiceFuture.fromResponse(getServicePrincipalsIdByAppIdWithServiceResponseAsync(applicationID), serviceCallback);
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @param applicationID The application ID.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalObjectResultInner object
*/
public Observable<ServicePrincipalObjectResultInner> getServicePrincipalsIdByAppIdAsync(String applicationID) {
return getServicePrincipalsIdByAppIdWithServiceResponseAsync(applicationID).map(new Func1<ServiceResponse<ServicePrincipalObjectResultInner>, ServicePrincipalObjectResultInner>() {
@Override
public ServicePrincipalObjectResultInner call(ServiceResponse<ServicePrincipalObjectResultInner> response) {
return response.body();
}
});
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @param applicationID The application ID.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalObjectResultInner object
*/
public Observable<ServiceResponse<ServicePrincipalObjectResultInner>> getServicePrincipalsIdByAppIdWithServiceResponseAsync(String applicationID) {
if (this.client.tenantID() == null) {
throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
}
if (applicationID == null) {
throw new IllegalArgumentException("Parameter applicationID is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.getServicePrincipalsIdByAppId(this.client.tenantID(), applicationID, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ServicePrincipalObjectResultInner>>>() {
@Override
public Observable<ServiceResponse<ServicePrincipalObjectResultInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ServicePrincipalObjectResultInner> clientResponse = getServicePrincipalsIdByAppIdDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<ServicePrincipalObjectResultInner> getServicePrincipalsIdByAppIdDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<ServicePrincipalObjectResultInner, GraphErrorException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<ServicePrincipalObjectResultInner>() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}

/**
* Gets a list of applications from the current tenant.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.graphrbac.implementation;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Service Principal Object Result.
*/
public class ServicePrincipalObjectResultInner {
/**
* The Object ID of the service principal with the specified application
* ID.
*/
@JsonProperty(value = "value")
private String value;

/**
* The URL representing edm equivalent.
*/
@JsonProperty(value = "odata\\.metadata")
private String odatametadata;

/**
* Get the Object ID of the service principal with the specified application ID.
*
* @return the value value
*/
public String value() {
return this.value;
}

/**
* Set the Object ID of the service principal with the specified application ID.
*
* @param value the value value to set
* @return the ServicePrincipalObjectResultInner object itself.
*/
public ServicePrincipalObjectResultInner withValue(String value) {
this.value = value;
return this;
}

/**
* Get the URL representing edm equivalent.
*
* @return the odatametadata value
*/
public String odatametadata() {
return this.odatametadata;
}

/**
* Set the URL representing edm equivalent.
*
* @param odatametadata the odatametadata value to set
* @return the ServicePrincipalObjectResultInner object itself.
*/
public ServicePrincipalObjectResultInner withOdatametadata(String odatametadata) {
this.odatametadata = odatametadata;
return this;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.graphrbac.implementation;

import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.graphrbac.GraphErrorException;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceResponse;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
* An instance of this class provides access to all the operations defined
* in ServicePrincipalsByAppIds.
*/
public class ServicePrincipalsByAppIdsInner {
/** The Retrofit service to perform REST calls. */
private ServicePrincipalsByAppIdsService service;
/** The service client containing this operation class. */
private GraphRbacManagementClientImpl client;

/**
* Initializes an instance of ServicePrincipalsByAppIdsInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public ServicePrincipalsByAppIdsInner(Retrofit retrofit, GraphRbacManagementClientImpl client) {
this.service = retrofit.create(ServicePrincipalsByAppIdsService.class);
this.client = client;
}

/**
* The interface defining all the services for ServicePrincipalsByAppIds to be
* used by Retrofit to perform actually REST calls.
*/
interface ServicePrincipalsByAppIdsService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.graphrbac.ServicePrincipalsByAppIds get" })
@GET("{tenantID}/servicePrincipalsByAppId/{applicationID}/objectId")
Observable<Response<ResponseBody>> get(@Path("tenantID") String tenantID, @Path("applicationID") String applicationID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

}

/**
* Gets an object id for a given application id from the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws GraphErrorException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ServicePrincipalObjectResultInner object if successful.
*/
public ServicePrincipalObjectResultInner get() {
return getWithServiceResponseAsync().toBlocking().single().body();
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<ServicePrincipalObjectResultInner> getAsync(final ServiceCallback<ServicePrincipalObjectResultInner> serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(), serviceCallback);
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalObjectResultInner object
*/
public Observable<ServicePrincipalObjectResultInner> getAsync() {
return getWithServiceResponseAsync().map(new Func1<ServiceResponse<ServicePrincipalObjectResultInner>, ServicePrincipalObjectResultInner>() {
@Override
public ServicePrincipalObjectResultInner call(ServiceResponse<ServicePrincipalObjectResultInner> response) {
return response.body();
}
});
}

/**
* Gets an object id for a given application id from the current tenant.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ServicePrincipalObjectResultInner object
*/
public Observable<ServiceResponse<ServicePrincipalObjectResultInner>> getWithServiceResponseAsync() {
if (this.client.tenantID() == null) {
throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
}
if (this.client.applicationID() == null) {
throw new IllegalArgumentException("Parameter this.client.applicationID() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.get(this.client.tenantID(), this.client.applicationID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ServicePrincipalObjectResultInner>>>() {
@Override
public Observable<ServiceResponse<ServicePrincipalObjectResultInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ServicePrincipalObjectResultInner> clientResponse = getDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<ServicePrincipalObjectResultInner> getDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<ServicePrincipalObjectResultInner, GraphErrorException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<ServicePrincipalObjectResultInner>() { }.getType())
.registerError(GraphErrorException.class)
.build(response);
}

}