Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support for Compute V2 Operations Client in OperationsResponse #565

Open
bshaffer opened this issue May 9, 2024 · 0 comments
Open

Support for Compute V2 Operations Client in OperationsResponse #565

bshaffer opened this issue May 9, 2024 · 0 comments

Comments

@bshaffer
Copy link
Contributor

bshaffer commented May 9, 2024

We need to modify the way the additional args are passed in from GAX. For example, in Compute's descriptor_config.php, we have the following:

'SomeRPCMethod' => [
    'longRunning' => [
        'additionalArgumentMethods' => [
            'getProject',
            'getZone',
        ],
        // ...
    ]
]

This is then passed into the OperationResponse class as $additionalArgs by GAX:

foreach ($descriptor['additionalArgumentMethods'] as $additionalArgsMethodName) {
$additionalArgs[] = $request->$additionalArgsMethodName();
}

But since these need to be set on the Request object, we could pass $additionalArgs in with array keys and use those in OperationResponse to set the fields on the Request.

Example (keys as protobuf field names):

// in descriptor_config.php
        'additionalArgumentMethods' => [
            'project' => 'getProject',
            'zone' => 'getZone',
        ],

// in OperationResponse::operationsCall
new $requestClass(['name' => $this->getName()] + $this->additionalArgs);

Example (keys as message setters):

// in descriptor_config.php
        'additionalArgumentMethods' => [
            'setProject' => 'getProject',
            'setZone' => 'getZone',
        ],

// in OperationResponse::operationsCall
$request = $requestClass::build($this->getName());
foreach ($this->additionalArgs as $setter => $value) {
    $request->$setter($value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant