Lazy loads the builder singleton.  Requires that ClientFactory::setCredentials has been previously
called and valid credentials have been given.

@throws \InvalidArgumentException When no credentials are set

@return ServiceBuilder
347501
protected static function getBuilder() {
		if((!ClientFactory::$_acct_num) || (!ClientFactory::$_email) || (!ClientFactory::$_password)) {
			// @codeCoverageIgnoreStart
			throw new InvalidArgumentException("No RightScale API credentials supplied, please call ClientFactory::setCredentials first.");
			// @codeCoverageIgnoreEnd
		}
		
		if (!ClientFactory::$_builder) {

			ClientFactory::$_builder = ServiceBuilder::factory(array(
					'guzzle-rs-1_0' => array (
							'class' => 'RGeyer\Guzzle\Rs\RightScaleClient',
							'params' => array_merge(array(
									'acct_num' 	=> ClientFactory::$_acct_num,
									'email' 		=> ClientFactory::$_email,
									'password' 	=> ClientFactory::$_password,
									'version' 	=> '1.0'
									), ClientFactory::$_additionalParams
							)
					),
					'guzzle-rs-1_5' => array (
							'class' => 'RGeyer\Guzzle\Rs\RightScaleClient',
							'params' => array_merge(array(
									'acct_num' 	=> ClientFactory::$_acct_num,
									'email' 		=> ClientFactory::$_email,
									'password' 	=> ClientFactory::$_password,
									'version' 	=> '1.5'
									), ClientFactory::$_additionalParams
							)
					)
			));
		}
		
		return ClientFactory::$_builder;
	}
271794
public function build(): RequestCachedResponseRequest
	{
		$instance = new RequestCachedResponseRequest();
		if ($this->cacheId === null) {
			throw new BuilderException('Property [cacheId] is required.');
		}
		$instance->cacheId = $this->cacheId;
		if ($this->requestURL === null) {
			throw new BuilderException('Property [requestURL] is required.');
		}
		$instance->requestURL = $this->requestURL;
		if ($this->requestHeaders === null) {
			throw new BuilderException('Property [requestHeaders] is required.');
		}
		$instance->requestHeaders = $this->requestHeaders;
		return $instance;
	}
122861
public function build(): RemoveScriptToEvaluateOnNewDocumentRequest
	{
		$instance = new RemoveScriptToEvaluateOnNewDocumentRequest();
		if ($this->identifier === null) {
			throw new BuilderException('Property [identifier] is required.');
		}
		$instance->identifier = $this->identifier;
		return $instance;
	}
1360805
public function build(): RemoveScriptToEvaluateOnLoadRequest
	{
		$instance = new RemoveScriptToEvaluateOnLoadRequest();
		if ($this->identifier === null) {
			throw new BuilderException('Property [identifier] is required.');
		}
		$instance->identifier = $this->identifier;
		return $instance;
	}
807377
public function build(): SetPausedRequest
	{
		$instance = new SetPausedRequest();
		if ($this->animations === null) {
			throw new BuilderException('Property [animations] is required.');
		}
		$instance->animations = $this->animations;
		if ($this->paused === null) {
			throw new BuilderException('Property [paused] is required.');
		}
		$instance->paused = $this->paused;
		return $instance;
	}
1114993
public function authenticate(array $credentials)
    {
        $loginProperty = $this->classMetadata->getPropertyName(ClassMetadata::LOGIN_PROPERTY);
        $passwordProperty = $this->classMetadata->getPropertyName(ClassMetadata::PASSWORD_PROPERTY);

        if (!array_key_exists($passwordProperty, $credentials)) {
            throw new \InvalidArgumentException(sprintf(
                'Unable to find password property "%s" in credential set!',
                $passwordProperty
            ));
        }

        if (!array_key_exists($loginProperty, $credentials)) {
            throw new \InvalidArgumentException(sprintf(
                'Unable to find login property "%s" in credential set!',
                $loginProperty
            ));
        }

        $object = $this->resolveObject($loginProperty, $credentials);

        if (!$this->validateCredentials($object, $credentials[$passwordProperty])) {
            $this->eventDispatcher->dispatch(
                Ma27ApiKeyAuthenticationEvents::CREDENTIAL_FAILURE,
                new OnInvalidCredentialsEvent($object)
            );

            throw new CredentialException();
        }

        $this->eventDispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::AUTHENTICATION, new OnAuthenticationEvent($object));
        $this->buildKey($object);

        $this->om->persist($object);
        $this->om->flush();

        return $object;
    }
781217
public function build(): ClearRequest
	{
		$instance = new ClearRequest();
		if ($this->storageId === null) {
			throw new BuilderException('Property [storageId] is required.');
		}
		$instance->storageId = $this->storageId;
		return $instance;
	}
257238
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('BjyAuthorize\Config');

        if (! isset($config['role_providers']['BjyAuthorize\Provider\Role\ObjectRepositoryProvider'])) {
            throw new InvalidArgumentException(
                'Config for "BjyAuthorize\Provider\Role\ObjectRepositoryProvider" not set'
            );
        }

        $providerConfig = $config['role_providers']['BjyAuthorize\Provider\Role\ObjectRepositoryProvider'];

        if (! isset($providerConfig['role_entity_class'])) {
            throw new InvalidArgumentException('role_entity_class not set in the bjyauthorize role_providers config.');
        }

        if (! isset($providerConfig['object_manager'])) {
            throw new InvalidArgumentException('object_manager not set in the bjyauthorize role_providers config.');
        }

        /* @var $objectManager \Doctrine\Common\Persistence\ObjectManager */
        $objectManager = $serviceLocator->get($providerConfig['object_manager']);

        return new ObjectRepositoryProvider($objectManager->getRepository($providerConfig['role_entity_class']));
    }
1017626
public function build(): GetUsageAndQuotaRequest
	{
		$instance = new GetUsageAndQuotaRequest();
		if ($this->origin === null) {
			throw new BuilderException('Property [origin] is required.');
		}
		$instance->origin = $this->origin;
		return $instance;
	}
770671
public ClientCredentialsRequest.Builder clientCredentials() {
    return new ClientCredentialsRequest.Builder(clientId, clientSecret)
            .setDefaults(httpManager, scheme, host, port)
            .grant_type("client_credentials");
  }
440800
public function build(): StartObservingRequest
	{
		$instance = new StartObservingRequest();
		if ($this->service === null) {
			throw new BuilderException('Property [service] is required.');
		}
		$instance->service = $this->service;
		return $instance;
	}
873309
public function build(): SetAsyncCallStackDepthRequest
	{
		$instance = new SetAsyncCallStackDepthRequest();
		if ($this->maxDepth === null) {
			throw new BuilderException('Property [maxDepth] is required.');
		}
		$instance->maxDepth = $this->maxDepth;
		return $instance;
	}
1081219
public static function factory($config = array()) {
        $default = array(
            'serverUrls' => null,
            'user' => null,
            'publicKey' => null,
            'privateKey' => null,
        );

        // Backwards-compatibility with old client where user === publicKey
        if (!isset($config['user']) && isset($config['publicKey'])) {
            $config['user'] = $config['publicKey'];
        }

        $required = array('serverUrls', 'publicKey', 'privateKey', 'user');
        $config = Collection::fromConfig($config, $default, $required);

        if (!is_array($serverUrls = $config->get('serverUrls')) || empty($serverUrls)) {
            throw new InvalidArgumentException('serverUrls must be an array');
        }

        // Create the client and attach the service description
        return new self($serverUrls[0], $config);
    }
573714
public function build(): RequestDatabaseNamesRequest
	{
		$instance = new RequestDatabaseNamesRequest();
		if ($this->securityOrigin === null) {
			throw new BuilderException('Property [securityOrigin] is required.');
		}
		$instance->securityOrigin = $this->securityOrigin;
		return $instance;
	}
1347217
public function build(): GetApplicationCacheForFrameRequest
	{
		$instance = new GetApplicationCacheForFrameRequest();
		if ($this->frameId === null) {
			throw new BuilderException('Property [frameId] is required.');
		}
		$instance->frameId = $this->frameId;
		return $instance;
	}
745370
public function newInstance()
    {
        // Set the file locators in each loader instance.
        foreach($this->loaders as $loader) {
            if(false === $loader instanceof LoaderInterface) {
                throw new \InvalidArgumentException("Loaders must implement Affiniti\Config\Loader\LoaderInterface.");
            }
            
            $loader->setLocator($this->fileLocator);
        }
        
        return new DelegatingLoader(new LoaderResolver($this->loaders));
    }
1359592
public function build(): SetScriptSourceRequest
	{
		$instance = new SetScriptSourceRequest();
		if ($this->scriptId === null) {
			throw new BuilderException('Property [scriptId] is required.');
		}
		$instance->scriptId = $this->scriptId;
		if ($this->scriptSource === null) {
			throw new BuilderException('Property [scriptSource] is required.');
		}
		$instance->scriptSource = $this->scriptSource;
		$instance->dryRun = $this->dryRun;
		return $instance;
	}