text:
package com.microsoft.azure.management.graphrbac.implementation;

import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.AzureServiceCall;
import com.microsoft.azure.AzureServiceResponseBuilder;
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.management.graphrbac.GraphErrorException;
import com.microsoft.azure.management.graphrbac.KeyCredentialsUpdateParameters;
import com.microsoft.azure.management.graphrbac.PasswordCredentialsUpdateParameters;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.Validator;
import java.io.IOException;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.HTTP;
import retrofit2.http.PATCH;
import retrofit2.http.Path;
import retrofit2.http.POST;
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 ServicePrincipals.
 */
public final class ServicePrincipalsInner {
    /** The Retrofit service to perform REST calls. */
    private ServicePrincipalsService service;
    /** The service client containing this operation class. */
    private GraphRbacManagementClientImpl client;

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

    /**
     * The interface defining all the services for ServicePrincipals to be
     * used by Retrofit to perform actually REST calls.
     */
    interface ServicePrincipalsService {
        @Headers("Content-Type: application/json; charset=utf-8")
        @POST("{tenantID}/servicePrincipals")
        Observable<Response<ResponseBody>> create(@Path("tenantID") String tenantID, @Body ServicePrincipalCreateParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @GET("{tenantID}/servicePrincipals")
        Observable<Response<ResponseBody>> list(@Path("tenantID") String tenantID, @Query("$filter") String filter, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @HTTP(path = "{tenantID}/servicePrincipals/{objectId}", method = "DELETE", hasBody = true)
        Observable<Response<ResponseBody>> delete(@Path(value = "objectId", encoded = true) String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @GET("{tenantID}/servicePrincipals/{objectId}")
        Observable<Response<ResponseBody>> get(@Path(value = "objectId", encoded = true) String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @GET("{tenantID}/servicePrincipals/{objectId}/keyCredentials")
        Observable<Response<ResponseBody>> listKeyCredentials(@Path(value = "objectId", encoded = true) String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @PATCH("{tenantID}/servicePrincipals/{objectId}/keyCredentials")
        Observable<Response<ResponseBody>> updateKeyCredentials(@Path(value = "objectId", encoded = true) String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCredentialsUpdateParameters parameters, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @GET("{tenantID}/servicePrincipals/{objectId}/passwordCredentials")
        Observable<Response<ResponseBody>> listPasswordCredentials(@Path(value = "objectId", encoded = true) String objectId, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers("Content-Type: application/json; charset=utf-8")
        @PATCH("{tenantID}/servicePrincipals/{objectId}/passwordCredentials")
        Observable<Response<ResponseBody>> updatePasswordCredentials(@Path(value = "objectId", encoded = true) String objectId, @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")
        @GET("{tenantID}/{nextLink}")
        Observable<Response<ResponseBody>> listNext(@Path(value = "nextLink", encoded = true) String nextLink, @Path("tenantID") String tenantID, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

    }

    /**
     * Creates a service principal in the  directory.
     *
     * @param parameters Parameters to create a service principal.
     * @return the ServicePrincipalInner object if successful.
     */
    public ServicePrincipalInner create(ServicePrincipalCreateParametersInner parameters) {
        return createWithServiceResponseAsync(parameters).toBlocking().single().getBody();
    }

    /**
     * Creates a service principal in the  directory.
     *
     * @param parameters Parameters to create a service principal.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<ServicePrincipalInner> createAsync(ServicePrincipalCreateParametersInner parameters, final ServiceCallback<ServicePrincipalInner> serviceCallback) {
        return ServiceCall.create(createWithServiceResponseAsync(parameters), serviceCallback);
    }

    /**
     * Creates a service principal in the  directory.
     *
     * @param parameters Parameters to create a service principal.
     * @return the observable to the ServicePrincipalInner object
     */
    public Observable<ServicePrincipalInner> createAsync(ServicePrincipalCreateParametersInner parameters) {
        return createWithServiceResponseAsync(parameters).map(new Func1<ServiceResponse<ServicePrincipalInner>, ServicePrincipalInner>() {
            @Override
            public ServicePrincipalInner call(ServiceResponse<ServicePrincipalInner> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Creates a service principal in the  directory.
     *
     * @param parameters Parameters to create a service principal.
     * @return the observable to the ServicePrincipalInner object
     */
    public Observable<ServiceResponse<ServicePrincipalInner>> createWithServiceResponseAsync(ServicePrincipalCreateParametersInner parameters) {
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
        }
        if (parameters == null) {
            throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(parameters);
        return service.create(this.client.tenantID(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ServicePrincipalInner>>>() {
                @Override
                public Observable<ServiceResponse<ServicePrincipalInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<ServicePrincipalInner> clientResponse = createDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<ServicePrincipalInner> createDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<ServicePrincipalInner, GraphErrorException>(this.client.mapperAdapter())
                .register(201, new TypeToken<ServicePrincipalInner>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @return the PagedList<ServicePrincipalInner> object if successful.
     */
    public PagedList<ServicePrincipalInner> list() {
        ServiceResponse<Page<ServicePrincipalInner>> response = listSinglePageAsync().toBlocking().single();
        return new PagedList<ServicePrincipalInner>(response.getBody()) {
            @Override
            public Page<ServicePrincipalInner> nextPage(String nextLink) {
                return listNextSinglePageAsync(nextLink).toBlocking().single().getBody();
            }
        };
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<List<ServicePrincipalInner>> listAsync(final ListOperationCallback<ServicePrincipalInner> serviceCallback) {
        return AzureServiceCall.create(
            listSinglePageAsync(),
            new Func1<String, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(String nextLink) {
                    return listNextSinglePageAsync(nextLink);
                }
            },
            serviceCallback);
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @return the observable to the PagedList<ServicePrincipalInner> object
     */
    public Observable<Page<ServicePrincipalInner>> listAsync() {
        return listWithServiceResponseAsync()
            .map(new Func1<ServiceResponse<Page<ServicePrincipalInner>>, Page<ServicePrincipalInner>>() {
                @Override
                public Page<ServicePrincipalInner> call(ServiceResponse<Page<ServicePrincipalInner>> response) {
                    return response.getBody();
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @return the observable to the PagedList<ServicePrincipalInner> object
     */
    public Observable<ServiceResponse<Page<ServicePrincipalInner>>> listWithServiceResponseAsync() {
        return listSinglePageAsync()
            .concatMap(new Func1<ServiceResponse<Page<ServicePrincipalInner>>, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(ServiceResponse<Page<ServicePrincipalInner>> page) {
                    String nextLink = page.getBody().getNextPageLink();
                    if (nextLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextLink));
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @return the PagedList<ServicePrincipalInner> object wrapped in {@link ServiceResponse} if successful.
     */
    public Observable<ServiceResponse<Page<ServicePrincipalInner>>> listSinglePageAsync() {
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final String filter = null;
        return service.list(this.client.tenantID(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl1<ServicePrincipalInner>> result = listDelegate(response);
                        return Observable.just(new ServiceResponse<Page<ServicePrincipalInner>>(result.getBody(), result.getResponse()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param filter The filter to apply on the operation.
     * @return the PagedList<ServicePrincipalInner> object if successful.
     */
    public PagedList<ServicePrincipalInner> list(final String filter) {
        ServiceResponse<Page<ServicePrincipalInner>> response = listSinglePageAsync(filter).toBlocking().single();
        return new PagedList<ServicePrincipalInner>(response.getBody()) {
            @Override
            public Page<ServicePrincipalInner> nextPage(String nextLink) {
                return listNextSinglePageAsync(nextLink).toBlocking().single().getBody();
            }
        };
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param filter The filter to apply on the operation.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<List<ServicePrincipalInner>> listAsync(final String filter, final ListOperationCallback<ServicePrincipalInner> serviceCallback) {
        return AzureServiceCall.create(
            listSinglePageAsync(filter),
            new Func1<String, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(String nextLink) {
                    return listNextSinglePageAsync(nextLink);
                }
            },
            serviceCallback);
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param filter The filter to apply on the operation.
     * @return the observable to the PagedList<ServicePrincipalInner> object
     */
    public Observable<Page<ServicePrincipalInner>> listAsync(final String filter) {
        return listWithServiceResponseAsync(filter)
            .map(new Func1<ServiceResponse<Page<ServicePrincipalInner>>, Page<ServicePrincipalInner>>() {
                @Override
                public Page<ServicePrincipalInner> call(ServiceResponse<Page<ServicePrincipalInner>> response) {
                    return response.getBody();
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param filter The filter to apply on the operation.
     * @return the observable to the PagedList<ServicePrincipalInner> object
     */
    public Observable<ServiceResponse<Page<ServicePrincipalInner>>> listWithServiceResponseAsync(final String filter) {
        return listSinglePageAsync(filter)
            .concatMap(new Func1<ServiceResponse<Page<ServicePrincipalInner>>, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(ServiceResponse<Page<ServicePrincipalInner>> page) {
                    String nextLink = page.getBody().getNextPageLink();
                    if (nextLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextLink));
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
    ServiceResponse<PageImpl1<ServicePrincipalInner>> * @param filter The filter to apply on the operation.
     * @return the PagedList<ServicePrincipalInner> object wrapped in {@link ServiceResponse} if successful.
     */
    public Observable<ServiceResponse<Page<ServicePrincipalInner>>> listSinglePageAsync(final String filter) {
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() 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.list(this.client.tenantID(), filter, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl1<ServicePrincipalInner>> result = listDelegate(response);
                        return Observable.just(new ServiceResponse<Page<ServicePrincipalInner>>(result.getBody(), result.getResponse()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PageImpl1<ServicePrincipalInner>> listDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<PageImpl1<ServicePrincipalInner>, GraphErrorException>(this.client.mapperAdapter())
                .register(200, new TypeToken<PageImpl1<ServicePrincipalInner>>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Deletes service principal from the directory.
     *
     * @param objectId Object id to delete service principal information.
     */
    public void delete(String objectId) {
        deleteWithServiceResponseAsync(objectId).toBlocking().single().getBody();
    }

    /**
     * Deletes service principal from the directory.
     *
     * @param objectId Object id to delete service principal information.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<Void> deleteAsync(String objectId, final ServiceCallback<Void> serviceCallback) {
        return ServiceCall.create(deleteWithServiceResponseAsync(objectId), serviceCallback);
    }

    /**
     * Deletes service principal from the directory.
     *
     * @param objectId Object id to delete service principal information.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> deleteAsync(String objectId) {
        return deleteWithServiceResponseAsync(objectId).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Deletes service principal from the directory.
     *
     * @param objectId Object id to delete service principal information.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String objectId) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() 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.delete(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = deleteDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<Void> deleteDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<Void, GraphErrorException>(this.client.mapperAdapter())
                .register(204, new TypeToken<Void>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Gets service principal information from the directory.
     *
     * @param objectId Object id to get service principal information.
     * @return the ServicePrincipalInner object if successful.
     */
    public ServicePrincipalInner get(String objectId) {
        return getWithServiceResponseAsync(objectId).toBlocking().single().getBody();
    }

    /**
     * Gets service principal information from the directory.
     *
     * @param objectId Object id to get service principal information.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<ServicePrincipalInner> getAsync(String objectId, final ServiceCallback<ServicePrincipalInner> serviceCallback) {
        return ServiceCall.create(getWithServiceResponseAsync(objectId), serviceCallback);
    }

    /**
     * Gets service principal information from the directory.
     *
     * @param objectId Object id to get service principal information.
     * @return the observable to the ServicePrincipalInner object
     */
    public Observable<ServicePrincipalInner> getAsync(String objectId) {
        return getWithServiceResponseAsync(objectId).map(new Func1<ServiceResponse<ServicePrincipalInner>, ServicePrincipalInner>() {
            @Override
            public ServicePrincipalInner call(ServiceResponse<ServicePrincipalInner> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Gets service principal information from the directory.
     *
     * @param objectId Object id to get service principal information.
     * @return the observable to the ServicePrincipalInner object
     */
    public Observable<ServiceResponse<ServicePrincipalInner>> getWithServiceResponseAsync(String objectId) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() 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(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ServicePrincipalInner>>>() {
                @Override
                public Observable<ServiceResponse<ServicePrincipalInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<ServicePrincipalInner> clientResponse = getDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<ServicePrincipalInner> getDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<ServicePrincipalInner, GraphErrorException>(this.client.mapperAdapter())
                .register(200, new TypeToken<ServicePrincipalInner>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Get keyCredentials associated with the service principal by object Id. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the List<KeyCredentialInner> object if successful.
     */
    public List<KeyCredentialInner> listKeyCredentials(String objectId) {
        return listKeyCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody();
    }

    /**
     * Get keyCredentials associated with the service principal by object Id. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<List<KeyCredentialInner>> listKeyCredentialsAsync(String objectId, final ServiceCallback<List<KeyCredentialInner>> serviceCallback) {
        return ServiceCall.create(listKeyCredentialsWithServiceResponseAsync(objectId), serviceCallback);
    }

    /**
     * Get keyCredentials associated with the service principal by object Id. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the observable to the List<KeyCredentialInner> object
     */
    public Observable<List<KeyCredentialInner>> listKeyCredentialsAsync(String objectId) {
        return listKeyCredentialsWithServiceResponseAsync(objectId).map(new Func1<ServiceResponse<List<KeyCredentialInner>>, List<KeyCredentialInner>>() {
            @Override
            public List<KeyCredentialInner> call(ServiceResponse<List<KeyCredentialInner>> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Get keyCredentials associated with the service principal by object Id. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the observable to the List<KeyCredentialInner> object
     */
    public Observable<ServiceResponse<List<KeyCredentialInner>>> listKeyCredentialsWithServiceResponseAsync(String objectId) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() 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.listKeyCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<KeyCredentialInner>>>>() {
                @Override
                public Observable<ServiceResponse<List<KeyCredentialInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl<KeyCredentialInner>> result = listKeyCredentialsDelegate(response);
                        ServiceResponse<List<KeyCredentialInner>> clientResponse = new ServiceResponse<List<KeyCredentialInner>>(result.getBody().getItems(), result.getResponse());
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PageImpl<KeyCredentialInner>> listKeyCredentialsDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<PageImpl<KeyCredentialInner>, GraphErrorException>(this.client.mapperAdapter())
                .register(200, new TypeToken<PageImpl<KeyCredentialInner>>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     */
    public void updateKeyCredentials(String objectId) {
        updateKeyCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody();
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<Void> updateKeyCredentialsAsync(String objectId, final ServiceCallback<Void> serviceCallback) {
        return ServiceCall.create(updateKeyCredentialsWithServiceResponseAsync(objectId), serviceCallback);
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> updateKeyCredentialsAsync(String objectId) {
        return updateKeyCredentialsWithServiceResponseAsync(objectId).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> updateKeyCredentialsWithServiceResponseAsync(String objectId) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final List<KeyCredentialInner> value = null;
        KeyCredentialsUpdateParameters parameters = new KeyCredentialsUpdateParameters();
        parameters.withValue(null);
        return service.updateKeyCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = updateKeyCredentialsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value KeyCredential list.
     */
    public void updateKeyCredentials(String objectId, List<KeyCredentialInner> value) {
        updateKeyCredentialsWithServiceResponseAsync(objectId, value).toBlocking().single().getBody();
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value KeyCredential list.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<Void> updateKeyCredentialsAsync(String objectId, List<KeyCredentialInner> value, final ServiceCallback<Void> serviceCallback) {
        return ServiceCall.create(updateKeyCredentialsWithServiceResponseAsync(objectId, value), serviceCallback);
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value KeyCredential list.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> updateKeyCredentialsAsync(String objectId, List<KeyCredentialInner> value) {
        return updateKeyCredentialsWithServiceResponseAsync(objectId, value).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Update keyCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#keycredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value KeyCredential list.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> updateKeyCredentialsWithServiceResponseAsync(String objectId, List<KeyCredentialInner> value) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(value);
        KeyCredentialsUpdateParameters parameters = new KeyCredentialsUpdateParameters();
        parameters.withValue(value);
        return service.updateKeyCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = updateKeyCredentialsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<Void> updateKeyCredentialsDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<Void, GraphErrorException>(this.client.mapperAdapter())
                .register(204, new TypeToken<Void>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Gets passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the List<PasswordCredentialInner> object if successful.
     */
    public List<PasswordCredentialInner> listPasswordCredentials(String objectId) {
        return listPasswordCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody();
    }

    /**
     * Gets passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<List<PasswordCredentialInner>> listPasswordCredentialsAsync(String objectId, final ServiceCallback<List<PasswordCredentialInner>> serviceCallback) {
        return ServiceCall.create(listPasswordCredentialsWithServiceResponseAsync(objectId), serviceCallback);
    }

    /**
     * Gets passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the observable to the List<PasswordCredentialInner> object
     */
    public Observable<List<PasswordCredentialInner>> listPasswordCredentialsAsync(String objectId) {
        return listPasswordCredentialsWithServiceResponseAsync(objectId).map(new Func1<ServiceResponse<List<PasswordCredentialInner>>, List<PasswordCredentialInner>>() {
            @Override
            public List<PasswordCredentialInner> call(ServiceResponse<List<PasswordCredentialInner>> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Gets passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the observable to the List<PasswordCredentialInner> object
     */
    public Observable<ServiceResponse<List<PasswordCredentialInner>>> listPasswordCredentialsWithServiceResponseAsync(String objectId) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() 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.listPasswordCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<PasswordCredentialInner>>>>() {
                @Override
                public Observable<ServiceResponse<List<PasswordCredentialInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl<PasswordCredentialInner>> result = listPasswordCredentialsDelegate(response);
                        ServiceResponse<List<PasswordCredentialInner>> clientResponse = new ServiceResponse<List<PasswordCredentialInner>>(result.getBody().getItems(), result.getResponse());
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PageImpl<PasswordCredentialInner>> listPasswordCredentialsDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<PageImpl<PasswordCredentialInner>, GraphErrorException>(this.client.mapperAdapter())
                .register(200, new TypeToken<PageImpl<PasswordCredentialInner>>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     */
    public void updatePasswordCredentials(String objectId) {
        updatePasswordCredentialsWithServiceResponseAsync(objectId).toBlocking().single().getBody();
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<Void> updatePasswordCredentialsAsync(String objectId, final ServiceCallback<Void> serviceCallback) {
        return ServiceCall.create(updatePasswordCredentialsWithServiceResponseAsync(objectId), serviceCallback);
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> updatePasswordCredentialsAsync(String objectId) {
        return updatePasswordCredentialsWithServiceResponseAsync(objectId).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> updatePasswordCredentialsWithServiceResponseAsync(String objectId) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final List<PasswordCredentialInner> value = null;
        PasswordCredentialsUpdateParameters parameters = new PasswordCredentialsUpdateParameters();
        parameters.withValue(null);
        return service.updatePasswordCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = updatePasswordCredentialsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value PasswordCredential list.
     */
    public void updatePasswordCredentials(String objectId, List<PasswordCredentialInner> value) {
        updatePasswordCredentialsWithServiceResponseAsync(objectId, value).toBlocking().single().getBody();
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value PasswordCredential list.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<Void> updatePasswordCredentialsAsync(String objectId, List<PasswordCredentialInner> value, final ServiceCallback<Void> serviceCallback) {
        return ServiceCall.create(updatePasswordCredentialsWithServiceResponseAsync(objectId, value), serviceCallback);
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value PasswordCredential list.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> updatePasswordCredentialsAsync(String objectId, List<PasswordCredentialInner> value) {
        return updatePasswordCredentialsWithServiceResponseAsync(objectId, value).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.getBody();
            }
        });
    }

    /**
     * Updates passwordCredentials associated with an existing service principal. Reference: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#passwordcredential-type.
     *
     * @param objectId Object id to get service principal information.
     * @param value PasswordCredential list.
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> updatePasswordCredentialsWithServiceResponseAsync(String objectId, List<PasswordCredentialInner> value) {
        if (objectId == null) {
            throw new IllegalArgumentException("Parameter objectId is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(value);
        PasswordCredentialsUpdateParameters parameters = new PasswordCredentialsUpdateParameters();
        parameters.withValue(value);
        return service.updatePasswordCredentials(objectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = updatePasswordCredentialsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<Void> updatePasswordCredentialsDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<Void, GraphErrorException>(this.client.mapperAdapter())
                .register(204, new TypeToken<Void>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param nextLink Next link for list operation.
     * @return the PagedList<ServicePrincipalInner> object if successful.
     */
    public PagedList<ServicePrincipalInner> listNext(final String nextLink) {
        ServiceResponse<Page<ServicePrincipalInner>> response = listNextSinglePageAsync(nextLink).toBlocking().single();
        return new PagedList<ServicePrincipalInner>(response.getBody()) {
            @Override
            public Page<ServicePrincipalInner> nextPage(String nextLink) {
                return listNextSinglePageAsync(nextLink).toBlocking().single().getBody();
            }
        };
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param nextLink Next link for list operation.
     * @param serviceCall the ServiceCall object tracking the Retrofit calls
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @return the {@link ServiceCall} object
     */
    public ServiceCall<List<ServicePrincipalInner>> listNextAsync(final String nextLink, final ServiceCall<List<ServicePrincipalInner>> serviceCall, final ListOperationCallback<ServicePrincipalInner> serviceCallback) {
        return AzureServiceCall.create(
            listNextSinglePageAsync(nextLink),
            new Func1<String, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(String nextLink) {
                    return listNextSinglePageAsync(nextLink);
                }
            },
            serviceCallback);
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param nextLink Next link for list operation.
     * @return the observable to the PagedList<ServicePrincipalInner> object
     */
    public Observable<Page<ServicePrincipalInner>> listNextAsync(final String nextLink) {
        return listNextWithServiceResponseAsync(nextLink)
            .map(new Func1<ServiceResponse<Page<ServicePrincipalInner>>, Page<ServicePrincipalInner>>() {
                @Override
                public Page<ServicePrincipalInner> call(ServiceResponse<Page<ServicePrincipalInner>> response) {
                    return response.getBody();
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
     * @param nextLink Next link for list operation.
     * @return the observable to the PagedList<ServicePrincipalInner> object
     */
    public Observable<ServiceResponse<Page<ServicePrincipalInner>>> listNextWithServiceResponseAsync(final String nextLink) {
        return listNextSinglePageAsync(nextLink)
            .concatMap(new Func1<ServiceResponse<Page<ServicePrincipalInner>>, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(ServiceResponse<Page<ServicePrincipalInner>> page) {
                    String nextLink = page.getBody().getNextPageLink();
                    if (nextLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextLink));
                }
            });
    }

    /**
     * Gets list of service principals from the current tenant.
     *
    ServiceResponse<PageImpl1<ServicePrincipalInner>> * @param nextLink Next link for list operation.
     * @return the PagedList<ServicePrincipalInner> object wrapped in {@link ServiceResponse} if successful.
     */
    public Observable<ServiceResponse<Page<ServicePrincipalInner>>> listNextSinglePageAsync(final String nextLink) {
        if (nextLink == null) {
            throw new IllegalArgumentException("Parameter nextLink is required and cannot be null.");
        }
        if (this.client.tenantID() == null) {
            throw new IllegalArgumentException("Parameter this.client.tenantID() 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.listNext(nextLink, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<ServicePrincipalInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<ServicePrincipalInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl1<ServicePrincipalInner>> result = listNextDelegate(response);
                        return Observable.just(new ServiceResponse<Page<ServicePrincipalInner>>(result.getBody(), result.getResponse()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PageImpl1<ServicePrincipalInner>> listNextDelegate(Response<ResponseBody> response) throws GraphErrorException, IOException, IllegalArgumentException {
        return new AzureServiceResponseBuilder<PageImpl1<ServicePrincipalInner>, GraphErrorException>(this.client.mapperAdapter())
                .register(200, new TypeToken<PageImpl1<ServicePrincipalInner>>() { }.getType())
                .registerError(GraphErrorException.class)
                .build(response);
    }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace Pegasus.DtsWrapper
{
    public class ISConditionalSplitOutput
    {
        #region Properties

        #region parent component

        private ISConditionalSplitComponent _parentComponent;

        #endregion

        #region ISOutput

        private ISOutput _output;

        #endregion

        #endregion

        #region ctor

        public ISConditionalSplitOutput(ISConditionalSplitComponent parentComponent, string outputName, int evaluationOrder, string condition, string conditionColumns = "")
        {
            _parentComponent = parentComponent;
            _output = new ISOutput(parentComponent, outputName);
            EvaluationOrder = evaluationOrder;
            SetFriendlyExpression(condition, conditionColumns);
        }

        #endregion

        #region Methods

        internal void SetFriendlyExpression(string condition, string conditionColumns = "")
        {
            IDTSInput100 _input = _parentComponent.ComponentMetaData.InputCollection[0];
            List<string> colArray = new List<string>();
            if (String.IsNullOrEmpty(conditionColumns))
            {
                foreach (IDTSVirtualInputColumn100 column in _input.GetVirtualInput().VirtualInputColumnCollection)
                    if (condition.Contains(column.Name))
                        colArray.Add(column.Name);
            }
            else
                colArray = conditionColumns.Split(',').ToList();

            foreach (string column in colArray)
                _parentComponent.SetInputColumnDTSUsageType(_input, column, UsageType.UT_READONLY);

            //_output.SetCustomProperty("FriendlyExpression", condition);
            _output.SetCustomProperty("Expression", condition);
        }

        #endregion

        #region Output Properties

        public int EvaluationOrder
        {
            get { return (int)_output.GetCustomPropertyValue("EvaluationOrder"); }
            set { _output.SetCustomProperty("EvaluationOrder", value); }
        }

        public string Expression
        {
            get { return (string)_output.GetCustomPropertyValue("Expression"); }
            set { SetFriendlyExpression(value, ""); }
        }

        #endregion
    }
}

redpajama_set_name: RedPajamaGithub


text:
{-# LANGUAGE OverloadedStrings #-}
module Main(main) where

import System.Console.GetOpt
import System.Environment (getArgs)
import Data.List (foldl', isSuffixOf)
import qualified Data.ByteString.Char8 as B
import System.IO
import Data.Aeson
import qualified Data.Map as M
import qualified Data.Vector as V
import Data.Aeson.Types (parseEither)
import Data.Either
import Data.Maybe
import System.Directory (doesFileExist, copyFile)
import Control.Monad.Trans.State
import qualified Data.Set as S
import Josh.Bootstrap (bootstrap)
import Josh.Visualizer (visualize, jsonValue)
import Control.Monad

data Flag = Output FilePath | LibPath FilePath | LibName String | Undefined String
                | Bootstrap FilePath | Visualize FilePath | Language String
                | IncludePath String deriving Show
data Config = Config { cOutput :: FilePath, cLibPaths :: [FilePath], cLibNames :: [String]
                    , cSpecial :: Maybe Flag } deriving Show
data SymInfo = SymInfo { siFile :: FilePath
                         , siOffset :: Integer
                         , siRegs :: [B.ByteString]
                         , siLength :: Int
                         , siCalls :: [B.ByteString] } deriving Show
type SymMap = M.Map B.ByteString SymInfo
type RegOffMap = (S.Set B.ByteString, [SymInfo])

options :: [OptDescr Flag]
options = [
            Option ['o'] [ "output" ] (ReqArg Output "OUTPUT") "Output into OUTPUT filename"
            , Option ['x'] [] (ReqArg Language "LANGUAGE") "Assume language of the input files"
            , Option ['I'] [] (ReqArg IncludePath "PATH") "Search for include files in PATH"
            , Option ['L'] [ "library-path" ] (ReqArg LibPath "PATH")
                "Search for libraries in PATH"
            , Option ['l'] [ "library" ] (ReqArg LibName "NAME") "Link with NAME library"
            , Option ['u'] [ "undefined" ] (ReqArg Undefined "SYMBOL")
                "Force SYMBOL as undefined"
            , Option [] [ "bootstrap" ] (ReqArg Bootstrap "CONFFILE")
                "Bootstrap GHC JavaScript installation"
            , Option [] [ "visualize" ] (ReqArg Visualize "LOGFILE")
                "Visualize trace file"
          ]

parseFlags :: [Flag] -> Config
parseFlags = foldl' go $ Config "a.out" [] [] Nothing where
    go c (Output f) = c { cOutput = f }
    go c (LibPath f) = c { cLibPaths = f:(cLibPaths c) }
    go c (LibName f) = c { cLibNames = f:(cLibNames c) }
    go c f@(Bootstrap _) = c { cSpecial = Just f }
    go c f@(Visualize _) = c { cSpecial = Just f }
    go c f@(Language _) = c { cSpecial = Just f }
    go c _ = c

markerBegin :: B.ByteString
markerBegin = "/* --josh-- ["

markerEnd :: B.ByteString
markerEnd = "] --josh-- */"

findInfos :: Handle -> IO ([Integer], [Integer])
findInfos h = go ([], []) where
    go res = do
        b <- hIsEOF h
        if b then return res
             else B.hGetLine h >>= more res >>= go
    more (bs, es) l | l == markerBegin = do o <- hTell h
                                            return ((o - 2):bs, es)
                    | l == markerEnd = do   o <- hTell h
                                            return (bs, (o - (toInteger $ B.length l)):es)
                    | otherwise = return (bs, es)

getBS :: Handle -> Integer -> Int -> IO B.ByteString
getBS h off len = hSeek h AbsoluteSeek off >> B.hGet h len

readInfoBytes :: Handle -> ([Integer], [Integer]) -> IO [B.ByteString]
readInfoBytes h = mapM go . uncurry zip where
    go (begin, end) = getBS h begin $ fromIntegral $ end - begin

parseSymbols :: FilePath -> Integer -> Value -> Either String SymMap
parseSymbols fp i = parseEither go where
    go (Array a) = do
        sis <- mapM syminfo $ V.toList a
        return $ M.fromList sis
    go j = fail $ "parseSymbols: bad root element: " ++ show j
    syminfo (Object o) = do
        sym <- o .: "name"
        off <- o .: "offset"
        len <- o .: "length"
        regs <- o .: "regs"
        calls <- o .: "calls"
        return (sym, SymInfo fp (i - off) regs len calls)
    syminfo j = fail $ "parseSymbols: bad function data: " ++ show j

loadSymbols :: FilePath -> IO [SymMap]
loadSymbols fp = withFile fp ReadMode go where
    go h = do
        is <- findInfos h
        bses <- readInfoBytes h is
        return $ rights $ map (uncurry (parseSymbols fp))
                        $ zip (map adj $ fst is) (map jsonValue bses)
    adj x = x - (toInteger $ B.length markerBegin) + 1

findLibrary :: [FilePath] -> String -> IO (Maybe FilePath)
findLibrary [] _ = return Nothing
findLibrary (x:xs) n = do
    b <- doesFileExist fn
    if b then return $ Just fn
         else findLibrary xs n
    where fn = x ++ "/lib" ++ n ++ ".a"

buildOffsetsMap :: [B.ByteString] -> State SymMap RegOffMap
buildOffsetsMap [] = return (S.empty, [])
buildOffsetsMap (x:xs) = do
    sm' <- get
    let (mv, sm) = M.updateLookupWithKey (\_ _ -> Nothing) x sm'
    p <- maybe (buildOffsetsMap []) ((put sm >>) . go) mv
    bu <- buildOffsetsMap xs
    return $ p `uni` bu
    where go si = do
            p <- buildOffsetsMap $ siCalls si
            return $ p `uni` (S.fromList $ siRegs si, [si])
          (rs1, offs1) `uni` (rs2, offs2) = (rs1 `S.union` rs2, offs1 ++ offs2)

initialStack :: [String]
initialStack = [ "stg_ap_v_info", "ZCMain_main_closure", "stg_enter_info" ]

writeSymInfo :: Handle -> Maybe (FilePath, Handle) -> SymInfo -> IO (Maybe (FilePath, Handle))
writeSymInfo h Nothing si = do
    rh <- openFile (siFile si) ReadMode
    getBS rh (siOffset si) (siLength si) >>= B.hPutStr h
    return $ Just ((siFile si), rh)
writeSymInfo h m@(Just (fp, rh)) si
    | siFile si == fp = do getBS rh (siOffset si) (siLength si) >>= B.hPutStr h
                           return m
    | otherwise = hClose rh >> writeSymInfo h Nothing si

type SymWrite = (Maybe (FilePath, Handle), S.Set (FilePath, Integer, Int))
writeSymInfoIfNeeded :: Handle -> SymWrite -> SymInfo -> IO SymWrite
writeSymInfoIfNeeded h t@(mb', set') si = if S.size set > S.size set'
    then do mb <- writeSymInfo h mb' si
            return (mb, set)
    else return t
    where set = S.insert (siFile si, siOffset si, siLength si) set'

writeOutput :: Maybe FilePath -> FilePath -> RegOffMap -> IO ()
writeOutput pjs fp (regs, offs) = withFile fp WriteMode go where
    go h = do
        maybe (return ()) (\p -> B.readFile p >>= B.hPutStr h) pjs

        B.hPutStr h "var "
        B.hPutStr h $ B.intercalate ", " $ S.toList $ S.delete "BaseReg" $ regs
        B.hPutStr h ";\n"

        foldM_ (writeSymInfoIfNeeded h) (Nothing, S.empty) offs
        hPutStr h $ "run_loop(createIOThread(null, null, ZCMain_main_closure));\n"

doLink :: Config -> [FilePath] -> IO ()
doLink cfg rest = do
    libs <- fmap catMaybes $ mapM (findLibrary $ cLibPaths cfg) $ cLibNames cfg
    syms <- mapM loadSymbols $ rest ++ libs
    pjs <- findLibrary (cLibPaths cfg) "ptr"
    writeOutput pjs (cOutput cfg) $ evalState (buildOffsetsMap $ map B.pack initialStack)
                                $ foldl' M.union M.empty $ concat syms

doLDScript :: FilePath -> FilePath -> IO ()
doLDScript ldf outf = do
    -- We expect ld script of the form: INPUT(x y)
    ld <- readFile ldf
    let os = words $ drop 1 $ takeWhile (/= ')') $ dropWhile (/= '(') ld
    withFile outf WriteMode (go os)
    where go :: [FilePath] -> Handle -> IO ()
          go os h = mapM_ (apnd h) os
          apnd h f = B.readFile f >>= B.hPutStr h

main :: IO ()
main = do
    (flags, rest, _) <- fmap (getOpt Permute options) getArgs
    let cfg = parseFlags flags
    maybe (pick_link cfg rest) (special cfg rest) $ cSpecial cfg
    where special _ _ (Bootstrap f) = bootstrap f
          special _ _ (Visualize f) = visualize f
          special cfg (x:_) (Language _) = copyFile x (cOutput cfg)
          special _ _ _ = return ()
          pick_link cfg (x:_) | ".ldscript" `isSuffixOf` x = doLDScript x (cOutput cfg)
          pick_link cfg rest = doLink cfg rest


text:
package com.example.android.servicesdemo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;

public class MyService extends Service {
  public MyService() {
  }

  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Toast.makeText(this, "Service started", Toast.LENGTH_SHORT).show();
    return super.onStartCommand(intent, flags, startId);
  }

  @Override
  public void onDestroy() {
    Toast.makeText(this, "Service stoped", Toast.LENGTH_SHORT).show();
    super.onDestroy();
  }

  @Override
  public IBinder onBind(Intent intent) {
    return null;
  }
}


text:
require 'spec_helper'
require 'yaml'

describe Puppet::Type.type(:netapp_storage_failover).provider(:cmode) do

  before :each do
    described_class.stubs(:suitable?).returns true
    Puppet::Type.type(:netapp_storage_failover).stubs(:defaultprovider).returns described_class
  end

  let :storage_array do
    Puppet::Type.type(:netapp_storage_failover).new(
      :name     => 'nodeA',
      :provider => provider
    )
  end

  let :provider do
    described_class.new(
      :name => 'nodeA'
    )
  end

  describe "#instances" do
    it "should return an array of current cf objects" do
      described_class.expects(:strgfailovershow).returns YAML.load_file(my_fixture('storage-failover-list.yml'))
      instances = described_class.instances
      instances.size.should == 1
      instances.map do |prov|
        {
          :name      => prov.get(:name),
          :auto_giveback => prov.get(:auto_giveback),
          :auto_giveback_after_panic => prov.get(:auto_giveback_after_panic),
          :auto_giveback_override_vetoes => prov.get(:auto_giveback_override_vetoes),

        }
      end.should == [
        {
          :name                          => 'nodeA',
          :auto_giveback                 => 'true',
          :auto_giveback_after_panic     => 'true',
          :auto_giveback_override_vetoes => 'true'
        }
      ]
    end
  end

  describe "#prefetch" do
    it "exists" do
      described_class.expects(:strgfailovershow).returns YAML.load_file(my_fixture('storage-failover-list.yml'))
      described_class.prefetch({})
    end
  end

  describe "when modifying a resource" do
    it "should be able to modify auto_giveback option" do
      storage_array.provider.set(:name => 'nodeA', :auto_giveback => 'true')
      storage_array[:auto_giveback] = 'false'
      storage_array.provider.expects(:strgfailovermdfy).with(is_a(NaElement))
      storage_array.provider.flush
    end

    it "should be able to modify auto_giveback_after_panic option" do
      storage_array.provider.set(:name => 'nodeA', :auto_giveback_after_panic => 'true')
      storage_array[:auto_giveback_after_panic] = 'false'
      storage_array.provider.expects(:strgfailovermdfy).with(is_a(NaElement))
      storage_array.provider.flush
    end

    it "should be able to modify auto_giveback_override_vetoes option" do
      storage_array.provider.set(:name => 'nodeA', :auto_giveback_override_vetoes => 'true')
      storage_array[:auto_giveback_override_vetoes] = 'false'
      storage_array.provider.expects(:strgfailovermdfy).with(is_a(NaElement))
      storage_array.provider.flush
    end
  end
end


text:
class CwmDebug {
 private:
  bool debug_;

 public:
  CwmDebug() { debug_ = false; }

  bool getDebug() { return debug_; }
  void setDebug(bool debug) { debug_ = debug; }

  void print(const std::string &msg);
};


text:
require 'rails_helper'

describe DeployRunnerJob, type: :job do
  it 'creates an event if another deploy is in progress' do
    job = DeployRunnerJob.new

    district_object = create :district
    heritage = create :heritage, district: district_object
    allow(job).to receive(:other_deploy_in_progress?) { true }

    event_object = double("Event")
    expect(event_object).to receive(:notify)

    expect(Event).to receive(:new).with(district_object) { event_object }

    job.perform(heritage, without_before_deploy: true, description: "meow")
  end
end


text:
LOG="/tmp/cpwpcheck.log"
EMAILS="" ## Separate with space

if [ ! -f /usr/bin/mutt ]; then
  echo "Mutt is not in /usr/bin, please check"
  exit 1
fi

rm -f $LOG

{
	echo -e "cPanel WordPress checkup starting. Trying to find every WP on this server and:\n"
	echo -e "- Find WP directory and version"
	echo -e "- Chmod wp-config.php to 600 to secure file reading"
	echo -e "\nProceeding.."
} 3>&1 4>&2 >>$LOG 2>&1

for vhost in $(grep DocumentRoot /usr/local/apache/conf/httpd.conf|grep "public_html\|subdomains" |awk -v vcol=2 '{print $vcol}'|sort|uniq -u); do
	find "$vhost" -wholename "*wp-includes/version.php" | while read wpverfile; do
		wpdir=$(echo "$wpverfile" | sed "s/\/wp-includes\/version.php//")
		echo -e "\n\nFound WP in : $wpdir" 3>&1 4>&2 >>$LOG 2>&1
		echo -e "WP version is: $(grep "^\$wp_version" "$wpverfile" | cut -d "'" -f 2)" 3>&1 4>&2 >>$LOG 2>&1
		chmod 600 "$wpdir/wp-config.php"
		wpconfigfile=$(ls -al "$wpdir/wp-config.php" |awk '{print $1,$3,$4}')
		echo -e "Configured wp-config permissions to 600: $wpconfigfile" 3>&1 4>&2 >>$LOG 2>&1
	done
done

echo -e "Here's the log of the cPanel WordPress daily checkup for $(hostname)." | mutt -a $LOG -s "cPanel WordPress daily checkup report for: $(hostname)" -- $EMAILS

rm -f /root/sent
rm -f $LOG


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StatePattern
{
    public class StandbyState : DVDPlayerState
    {
        public StandbyState()
        {
            Console.WriteLine("STANDBY");
        }

        public override void PlayButtonPressed(DVDPlayer player)
        {
            player.State = new MoviePlayingState();
        }

        public override void MenuButtonPressed(DVDPlayer player)
        {
            player.State = new MenuState();
        }
    }
}


text:
layout: post
title: A Milf Fucks Her Babysitter
titleinfo: pornvd
desc: Watch A Milf Fucks Her Babysitter. Pornhub is the ultimate xxx porn and sex site.
---

A Milf Fucks Her Babysitter

Watch A Milf Fucks Her Babysitter. Pornhub is the ultimate xxx porn and sex site.


text:
sudo python ~/bin/get-pip.py
sudo ~/bin/install.docker.sh


text:
package models

import (
	"bytes"
	"context"
	"reflect"
	"testing"

	"github.com/volatiletech/sqlboiler/boil"
	"github.com/volatiletech/sqlboiler/queries"
	"github.com/volatiletech/sqlboiler/randomize"
	"github.com/volatiletech/sqlboiler/strmangle"
)

var (
	// Relationships sometimes use the reflection helper queries.Equal/queries.Assign
	// so force a package dependency in case they don't.
	_ = queries.Equal
)

func testUserLinkReviews(t *testing.T) {
	t.Parallel()

	query := UserLinkReviews()

	if query.Query == nil {
		t.Error("expected a query, got nothing")
	}
}

func testUserLinkReviewsDelete(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	if rowsAff, err := o.Delete(ctx, tx); err != nil {
		t.Error(err)
	} else if rowsAff != 1 {
		t.Error("should only have deleted one row, but affected:", rowsAff)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

func testUserLinkReviewsQueryDeleteAll(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	if rowsAff, err := UserLinkReviews().DeleteAll(ctx, tx); err != nil {
		t.Error(err)
	} else if rowsAff != 1 {
		t.Error("should only have deleted one row, but affected:", rowsAff)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

func testUserLinkReviewsSliceDeleteAll(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	slice := UserLinkReviewSlice{o}

	if rowsAff, err := slice.DeleteAll(ctx, tx); err != nil {
		t.Error(err)
	} else if rowsAff != 1 {
		t.Error("should only have deleted one row, but affected:", rowsAff)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

func testUserLinkReviewsExists(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	e, err := UserLinkReviewExists(ctx, tx, o.UserID, o.LinkID)
	if err != nil {
		t.Errorf("Unable to check if UserLinkReview exists: %s", err)
	}
	if !e {
		t.Errorf("Expected UserLinkReviewExists to return true, but got false.")
	}
}

func testUserLinkReviewsFind(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	userLinkReviewFound, err := FindUserLinkReview(ctx, tx, o.UserID, o.LinkID)
	if err != nil {
		t.Error(err)
	}

	if userLinkReviewFound == nil {
		t.Error("want a record, got nil")
	}
}

func testUserLinkReviewsBind(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	if err = UserLinkReviews().Bind(ctx, tx, o); err != nil {
		t.Error(err)
	}
}

func testUserLinkReviewsOne(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	if x, err := UserLinkReviews().One(ctx, tx); err != nil {
		t.Error(err)
	} else if x == nil {
		t.Error("expected to get a non nil record")
	}
}

func testUserLinkReviewsAll(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	userLinkReviewOne := &UserLinkReview{}
	userLinkReviewTwo := &UserLinkReview{}
	if err = randomize.Struct(seed, userLinkReviewOne, userLinkReviewDBTypes, false, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}
	if err = randomize.Struct(seed, userLinkReviewTwo, userLinkReviewDBTypes, false, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = userLinkReviewOne.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}
	if err = userLinkReviewTwo.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	slice, err := UserLinkReviews().All(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 2 {
		t.Error("want 2 records, got:", len(slice))
	}
}

func testUserLinkReviewsCount(t *testing.T) {
	t.Parallel()

	var err error
	seed := randomize.NewSeed()
	userLinkReviewOne := &UserLinkReview{}
	userLinkReviewTwo := &UserLinkReview{}
	if err = randomize.Struct(seed, userLinkReviewOne, userLinkReviewDBTypes, false, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}
	if err = randomize.Struct(seed, userLinkReviewTwo, userLinkReviewDBTypes, false, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = userLinkReviewOne.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}
	if err = userLinkReviewTwo.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 2 {
		t.Error("want 2 records, got:", count)
	}
}

func testUserLinkReviewsInsert(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}

func testUserLinkReviewsInsertWhitelist(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Whitelist(userLinkReviewColumnsWithoutDefault...)); err != nil {
		t.Error(err)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}

func testUserLinkReviewToOneLinkUsingLink(t *testing.T) {
	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()

	var local UserLinkReview
	var foreign Link

	seed := randomize.NewSeed()
	if err := randomize.Struct(seed, &local, userLinkReviewDBTypes, false, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}
	if err := randomize.Struct(seed, &foreign, linkDBTypes, false, linkColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Link struct: %s", err)
	}

	if err := foreign.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}

	local.LinkID = foreign.ID
	if err := local.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}

	check, err := local.Link().One(ctx, tx)
	if err != nil {
		t.Fatal(err)
	}

	if check.ID != foreign.ID {
		t.Errorf("want: %v, got %v", foreign.ID, check.ID)
	}

	slice := UserLinkReviewSlice{&local}
	if err = local.L.LoadLink(ctx, tx, false, (*[]*UserLinkReview)(&slice), nil); err != nil {
		t.Fatal(err)
	}
	if local.R.Link == nil {
		t.Error("struct should have been eager loaded")
	}

	local.R.Link = nil
	if err = local.L.LoadLink(ctx, tx, true, &local, nil); err != nil {
		t.Fatal(err)
	}
	if local.R.Link == nil {
		t.Error("struct should have been eager loaded")
	}
}

func testUserLinkReviewToOneUserUsingUser(t *testing.T) {
	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()

	var local UserLinkReview
	var foreign User

	seed := randomize.NewSeed()
	if err := randomize.Struct(seed, &local, userLinkReviewDBTypes, false, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}
	if err := randomize.Struct(seed, &foreign, userDBTypes, false, userColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize User struct: %s", err)
	}

	if err := foreign.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}

	local.UserID = foreign.ID
	if err := local.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}

	check, err := local.User().One(ctx, tx)
	if err != nil {
		t.Fatal(err)
	}

	if check.ID != foreign.ID {
		t.Errorf("want: %v, got %v", foreign.ID, check.ID)
	}

	slice := UserLinkReviewSlice{&local}
	if err = local.L.LoadUser(ctx, tx, false, (*[]*UserLinkReview)(&slice), nil); err != nil {
		t.Fatal(err)
	}
	if local.R.User == nil {
		t.Error("struct should have been eager loaded")
	}

	local.R.User = nil
	if err = local.L.LoadUser(ctx, tx, true, &local, nil); err != nil {
		t.Fatal(err)
	}
	if local.R.User == nil {
		t.Error("struct should have been eager loaded")
	}
}

func testUserLinkReviewToOneSetOpLinkUsingLink(t *testing.T) {
	var err error

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()

	var a UserLinkReview
	var b, c Link

	seed := randomize.NewSeed()
	if err = randomize.Struct(seed, &a, userLinkReviewDBTypes, false, strmangle.SetComplement(userLinkReviewPrimaryKeyColumns, userLinkReviewColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &b, linkDBTypes, false, strmangle.SetComplement(linkPrimaryKeyColumns, linkColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &c, linkDBTypes, false, strmangle.SetComplement(linkPrimaryKeyColumns, linkColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}

	if err := a.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}
	if err = b.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}

	for i, x := range []*Link{&b, &c} {
		err = a.SetLink(ctx, tx, i != 0, x)
		if err != nil {
			t.Fatal(err)
		}

		if a.R.Link != x {
			t.Error("relationship struct not set to correct value")
		}

		if x.R.UserLinkReviews[0] != &a {
			t.Error("failed to append to foreign relationship struct")
		}
		if a.LinkID != x.ID {
			t.Error("foreign key was wrong value", a.LinkID)
		}

		if exists, err := UserLinkReviewExists(ctx, tx, a.UserID, a.LinkID); err != nil {
			t.Fatal(err)
		} else if !exists {
			t.Error("want 'a' to exist")
		}

	}
}
func testUserLinkReviewToOneSetOpUserUsingUser(t *testing.T) {
	var err error

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()

	var a UserLinkReview
	var b, c User

	seed := randomize.NewSeed()
	if err = randomize.Struct(seed, &a, userLinkReviewDBTypes, false, strmangle.SetComplement(userLinkReviewPrimaryKeyColumns, userLinkReviewColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &b, userDBTypes, false, strmangle.SetComplement(userPrimaryKeyColumns, userColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &c, userDBTypes, false, strmangle.SetComplement(userPrimaryKeyColumns, userColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}

	if err := a.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}
	if err = b.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Fatal(err)
	}

	for i, x := range []*User{&b, &c} {
		err = a.SetUser(ctx, tx, i != 0, x)
		if err != nil {
			t.Fatal(err)
		}

		if a.R.User != x {
			t.Error("relationship struct not set to correct value")
		}

		if x.R.UserLinkReviews[0] != &a {
			t.Error("failed to append to foreign relationship struct")
		}
		if a.UserID != x.ID {
			t.Error("foreign key was wrong value", a.UserID)
		}

		if exists, err := UserLinkReviewExists(ctx, tx, a.UserID, a.LinkID); err != nil {
			t.Fatal(err)
		} else if !exists {
			t.Error("want 'a' to exist")
		}

	}
}

func testUserLinkReviewsReload(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	if err = o.Reload(ctx, tx); err != nil {
		t.Error(err)
	}
}

func testUserLinkReviewsReloadAll(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	slice := UserLinkReviewSlice{o}

	if err = slice.ReloadAll(ctx, tx); err != nil {
		t.Error(err)
	}
}

func testUserLinkReviewsSelect(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	slice, err := UserLinkReviews().All(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 1 {
		t.Error("want one record, got:", len(slice))
	}
}

var (
	userLinkReviewDBTypes = map[string]string{`UserID`: `uuid`, `LinkID`: `uuid`, `CreatedAt`: `timestamp with time zone`, `UpdatedAt`: `timestamp with time zone`, `ReviewedAt`: `timestamp with time zone`}
	_                     = bytes.MinRead
)

func testUserLinkReviewsUpdate(t *testing.T) {
	t.Parallel()

	if 0 == len(userLinkReviewPrimaryKeyColumns) {
		t.Skip("Skipping table with no primary key columns")
	}
	if len(userLinkReviewAllColumns) == len(userLinkReviewPrimaryKeyColumns) {
		t.Skip("Skipping table with only primary key columns")
	}

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}

	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewPrimaryKeyColumns...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	if rowsAff, err := o.Update(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	} else if rowsAff != 1 {
		t.Error("should only affect one row but affected", rowsAff)
	}
}

func testUserLinkReviewsSliceUpdateAll(t *testing.T) {
	t.Parallel()

	if len(userLinkReviewAllColumns) == len(userLinkReviewPrimaryKeyColumns) {
		t.Skip("Skipping table with only primary key columns")
	}

	seed := randomize.NewSeed()
	var err error
	o := &UserLinkReview{}
	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
		t.Error(err)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}

	if err = randomize.Struct(seed, o, userLinkReviewDBTypes, true, userLinkReviewPrimaryKeyColumns...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	// Remove Primary keys and unique columns from what we plan to update
	var fields []string
	if strmangle.StringSliceMatch(userLinkReviewAllColumns, userLinkReviewPrimaryKeyColumns) {
		fields = userLinkReviewAllColumns
	} else {
		fields = strmangle.SetComplement(
			userLinkReviewAllColumns,
			userLinkReviewPrimaryKeyColumns,
		)
	}

	value := reflect.Indirect(reflect.ValueOf(o))
	typ := reflect.TypeOf(o).Elem()
	n := typ.NumField()

	updateMap := M{}
	for _, col := range fields {
		for i := 0; i < n; i++ {
			f := typ.Field(i)
			if f.Tag.Get("boil") == col {
				updateMap[col] = value.Field(i).Interface()
			}
		}
	}

	slice := UserLinkReviewSlice{o}
	if rowsAff, err := slice.UpdateAll(ctx, tx, updateMap); err != nil {
		t.Error(err)
	} else if rowsAff != 1 {
		t.Error("wanted one record updated but got", rowsAff)
	}
}

func testUserLinkReviewsUpsert(t *testing.T) {
	t.Parallel()

	if len(userLinkReviewAllColumns) == len(userLinkReviewPrimaryKeyColumns) {
		t.Skip("Skipping table with only primary key columns")
	}

	seed := randomize.NewSeed()
	var err error
	// Attempt the INSERT side of an UPSERT
	o := UserLinkReview{}
	if err = randomize.Struct(seed, &o, userLinkReviewDBTypes, true); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	ctx := context.Background()
	tx := MustTx(boil.BeginTx(ctx, nil))
	defer func() { _ = tx.Rollback() }()
	if err = o.Upsert(ctx, tx, false, nil, boil.Infer(), boil.Infer()); err != nil {
		t.Errorf("Unable to upsert UserLinkReview: %s", err)
	}

	count, err := UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}
	if count != 1 {
		t.Error("want one record, got:", count)
	}

	// Attempt the UPDATE side of an UPSERT
	if err = randomize.Struct(seed, &o, userLinkReviewDBTypes, false, userLinkReviewPrimaryKeyColumns...); err != nil {
		t.Errorf("Unable to randomize UserLinkReview struct: %s", err)
	}

	if err = o.Upsert(ctx, tx, true, nil, boil.Infer(), boil.Infer()); err != nil {
		t.Errorf("Unable to upsert UserLinkReview: %s", err)
	}

	count, err = UserLinkReviews().Count(ctx, tx)
	if err != nil {
		t.Error(err)
	}
	if count != 1 {
		t.Error("want one record, got:", count)
	}
}


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_cat_82_bad.cpp
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_dest.label.xml
Template File: sources-sink-82_bad.tmpl.cpp
*/
/*
 * @description
 * CWE: 122 Heap Based Buffer Overflow
 * BadSource:  Allocate using new[] and set data pointer to a small buffer
 * GoodSource: Allocate using new[] and set data pointer to a large buffer
 * Sinks: cat
 *    BadSink : Copy string to data using strcat
 * Flow Variant: 82 Data flow: data passed in a parameter to a virtual method called via a pointer
 *
 * */
#ifndef OMITBAD

#include "std_testcase.h"
#include "CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_cat_82.h"

namespace CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_cat_82
{

void CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_cat_82_bad::action(char * data)
{
    {
        char source[100];
        memset(source, 'C', 100-1); /* fill with 'C's */
        source[100-1] = '\0'; /* null terminate */
        /* POTENTIAL FLAW: Possible buffer overflow if source is larger than sizeof(data)-strlen(data) */
        strcat(data, source);
        printLine(data);
        delete [] data;
    }
}

}
#endif /* OMITBAD */


text:
module Troles::Adapters::ActiveRecord
  class Config < Troles::Common::Config

    attr_reader :models

    def initialize subject_class, options = {}
      super
      puts "models classes: #{subject_class}, #{object_model}, #{join_model}"
      @models = ::Schemaker::Models.new(subject_class, object_model, join_model)
    end

    def configure_relation
      case strategy
      when :join_ref_many
        configure_join_model
      when :ref_many
        return configure_join_model if join_model?
        subject.quick_join
      when :embed_many
        raise "Embed many configuration not yet implemented for ActiveRecord"
      end
    end

    # AR sets this up ont its own using DB Table info
    def configure_field
    end

    protected

    def subject
      @subject ||= models.subject_model
    end

    def main_field
      role_field
    end

    def join_model
      @join_model_found ||= begin
        find_first_class(@join_model, join_model_best_guess)
      end
    rescue ClassExt::ClassNotFoundError
      nil
    end

    def join_model?
      join_model
    end

    def join_model_best_guess
      "#{subject_class.to_s.pluralize}#{object_model.to_s.pluralize}"
    end

    def join_model= model_class
      @join_model = model_class and return if model_class.any_kind_of?(Class, String, Symbol)
      raise "The join model must be a Class, was: #{model_class}"
    end

    def join_key
      make_key join_model
    end

    def configure_join_model
      if Troles::Common::Config.log_on?
        puts "configuring join model..."
        puts "Subject class: #{subject_class}"
        puts "Role class: #{object_model}"
        puts "Join class: #{join_model}"
      end

      [:object, :subject, :join].each do |type|
        clazz = "Schemaker::#{type.to_s.camelize}Model".constantize
        clazz.new(model).configure
      end
    end
  end
end


text:
<!DOCTYPE html>

	<title>Align</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>

	<input type="button" value="Left Align" onclick="myMenu.setAlign('left');">
	<input type="button" value="Right Align" onclick="myMenu.setAlign('right');">