Run the given method on the given container.

Checks to see if the expected result is returned.

@param string $name
The name of the container.
@param string $method
The appropriate HTTP verb.
@param int $expects
The expected HTTP code.
964711
protected function modifyContainer($name, $method, $headers = array(), $qstring = '') {
    $url = $this->url . '/' . rawurlencode($name) . $qstring;
    $headers['X-Auth-Token'] = $this->token;

    $client = \HPCloud\Transport::instance();
    $response = $client->doRequest($url, $method, $headers);

    return $response;
  }
1337756
public function resolveStatic(string $name, string $method, ...$args)
    {
        return $this->resolve($name . '::' . $method, ...$args);
    }
308122
public function call($name, $arguments, $expected_class = null)
  {
    if (! isset($this->methods[$name])) {
      $this->client->getLogger()->error(
          'Service method unknown',
          array(
              'service' => $this->serviceName,
              'resource' => $this->resourceName,
              'method' => $name
          )
      );

      throw new Google_Exception(
          "Unknown function: " .
          "{$this->serviceName}->{$this->resourceName}->{$name}()"
      );
    }
    $method = $this->methods[$name];
    $parameters = $arguments[0];

    // postBody is a special case since it's not defined in the discovery
    // document as parameter, but we abuse the param entry for storing it.
    $postBody = null;
    if (isset($parameters['postBody'])) {
      if ($parameters['postBody'] instanceof Google_Model) {
        // In the cases the post body is an existing object, we want
        // to use the smart method to create a simple object for
        // for JSONification.
        $parameters['postBody'] = $parameters['postBody']->toSimpleObject();
      } else if (is_object($parameters['postBody'])) {
        // If the post body is another kind of object, we will try and
        // wrangle it into a sensible format.
        $parameters['postBody'] =
            $this->convertToArrayAndStripNulls($parameters['postBody']);
      }
      $postBody = json_encode($parameters['postBody']);
      unset($parameters['postBody']);
    }

    // TODO(ianbarber): optParams here probably should have been
    // handled already - this may well be redundant code.
    if (isset($parameters['optParams'])) {
      $optParams = $parameters['optParams'];
      unset($parameters['optParams']);
      $parameters = array_merge($parameters, $optParams);
    }

    if (!isset($method['parameters'])) {
      $method['parameters'] = array();
    }

    $method['parameters'] = array_merge(
        $method['parameters'],
        $this->stackParameters
    );
    foreach ($parameters as $key => $val) {
      if ($key != 'postBody' && ! isset($method['parameters'][$key])) {
        $this->client->getLogger()->error(
            'Service parameter unknown',
            array(
                'service' => $this->serviceName,
                'resource' => $this->resourceName,
                'method' => $name,
                'parameter' => $key
            )
        );
        throw new Google_Exception("($name) unknown parameter: '$key'");
      }
    }

    foreach ($method['parameters'] as $paramName => $paramSpec) {
      if (isset($paramSpec['required']) &&
          $paramSpec['required'] &&
          ! isset($parameters[$paramName])
      ) {
        $this->client->getLogger()->error(
            'Service parameter missing',
            array(
                'service' => $this->serviceName,
                'resource' => $this->resourceName,
                'method' => $name,
                'parameter' => $paramName
            )
        );
        throw new Google_Exception("($name) missing required param: '$paramName'");
      }
      if (isset($parameters[$paramName])) {
        $value = $parameters[$paramName];
        $parameters[$paramName] = $paramSpec;
        $parameters[$paramName]['value'] = $value;
        unset($parameters[$paramName]['required']);
      } else {
        // Ensure we don't pass nulls.
        unset($parameters[$paramName]);
      }
    }

    $this->client->getLogger()->info(
        'Service Call',
        array(
            'service' => $this->serviceName,
            'resource' => $this->resourceName,
            'method' => $name,
            'arguments' => $parameters,
        )
    );

    $url = Google_Http_REST::createRequestUri(
        $this->servicePath,
        $method['path'],
        $parameters
    );
    $httpRequest = new Google_Http_Request(
        $url,
        $method['httpMethod'],
        null,
        $postBody
    );

    if ($this->rootUrl) {
      $httpRequest->setBaseComponent($this->rootUrl);
    } else {
      $httpRequest->setBaseComponent($this->client->getBasePath());
    }

    if ($postBody) {
      $contentTypeHeader = array();
      $contentTypeHeader['content-type'] = 'application/json; charset=UTF-8';
      $httpRequest->setRequestHeaders($contentTypeHeader);
      $httpRequest->setPostBody($postBody);
    }

    $httpRequest = $this->client->getAuth()->sign($httpRequest);
    $httpRequest->setExpectedClass($expected_class);

    if (isset($parameters['data']) &&
        ($parameters['uploadType']['value'] == 'media' || $parameters['uploadType']['value'] == 'multipart')) {
      // If we are doing a simple media upload, trigger that as a convenience.
      $mfu = new Google_Http_MediaFileUpload(
          $this->client,
          $httpRequest,
          isset($parameters['mimeType']) ? $parameters['mimeType']['value'] : 'application/octet-stream',
          $parameters['data']['value']
      );
    }

    if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
      $httpRequest->enableExpectedRaw();
    }

    if ($this->client->shouldDefer()) {
      // If we are in batch or upload mode, return the raw request.
      return $httpRequest;
    }

    return $this->client->execute($httpRequest);
  }
148495
protected function run($method, $args) {
		$request = $this->request();
		$request->method($method);
		$request->resource(array_shift($args));
		if (count($args)) {
			$request->params(array_shift($args));
		}
		if (count($args)) {
			$request->files(array_shift($args));
		}
		return $request->send();
	}
1241222
public function method($name)
    {
        $method = new Method($name);
        $this->container->put($name, $method);

        return $method;
    }
343267
public function assertParameters($name, $expected) {
    $value = \Drupal::getContainer()->getParameter($name);
    Assert::eq($value, $this->castParameter($expected));
  }
210634
private function initMethod(object $object, string $method, bool $expected): void
    {
        if (!$this->mustBeInitialized($object, $method)) {
            return;
        }

        $this->object = $object;
        $this->method = $method;
        $this->expected = $expected;
    }
1340531
public function helperMethod($name, $method, $args)
    {
        $args[0] = $this->helperName($name);
        $dependencies = $this->formatter->getDependencies();

        return call_user_func_array([$dependencies, $method], $args);
    }
458360
public function addMethod(Method $method): void
    {
        $this->methods[(string) $method->getFqsen()] = $method;
    }
1159411
public static function verifyInstanceOf(string $method, string $name, $argument, string $class)
    {
        static::verify(
                $argument instanceof $class,
                self::messageFormat($method, $name, 'expecting instance of %s, %s given'),
                $class,
                Debug::getType($argument)
        );
    }
870815
protected function processWith($instance, string $name, string $method, ...$parameters)
    {
        $processor = $this->getVersionedResourceClassName('Processors', $name);

        return \app($processor)->{$method}($this, $instance, ...$parameters);
    }
624998
protected function doRun($method, array $args=[]) {
		ob_start();
		$result = call_user_func_array($method, array_merge([$this], $args));
		$controllerBuffer =  ob_get_clean();

		if($result !== null)
			return $result;
		if($controllerBuffer)
			return $controllerBuffer;
		return null;
	}
586448
public function setService($name, $service)
    {
        $this->validate($service);
        parent::setService($name, $service);
    }
481650
public function check( $method = NULL ){
		$method			= $this->method;
		if( $method && $this->validateMethod( $method ) )
			$method		= $method;
		$currentStatus	= $this->status;
		switch( $method ){
			case self::METHOD_SOCKET:
				$this->checkUsingSocket();
				break;
			case self::METHOD_PING:
				$this->checkUsingSystemPing();
				break;
		}
		if( $this->status !== $currentStatus ){
			if( $this->callbackOnChange ){
				call_user_func_array( $this->callbackOnChange, array( $this->status ) );
			}
		}
	}
1022934
private function assertMethodExists(string $method): void
    {
        if (!method_exists($this, $method)) {
            throw new MethodDoesNotExistException(
                sprintf("Specified method \"%s\" does not exist", $method)
            );
        }
    }
1208710
private function recurseRelationship($method, $name, $type = 'one')
    {
        $dataset = $this->getParameters('dataset', $name);

        // Assume by default this will pass
        $result = true;

        if ($type == 'one')
        {
            $result = $this->recurseRecord($method, $name, $dataset);
        }
        else
        {
            foreach ($dataset as $index => $data)
            {
                $subresult = $this->recurseRecord($method, $name, $data, $index);

                // Relationship failures are failures
                if ( ! $subresult) $result = false;
            }
        }

        // A positive result and no errors mean action was successful
        return ($result && $this->errors->count() === 0);
    }
718854
protected function objectBuild($name, $method)
    {
        if (!$this->hasInstance($name))
        {
            $this->instances[$name] = $this->init($method);
        }

        return $this->instances[$name];
    }