add read log query parameters
Closed this issue ยท 7 comments
/**
* read log of the specified Pod
*
* @param $namespace
* @param $name
* @return string|mixed
*/
public function readLog($namespace = 'default', $name)
{
return $this->parseResponse(
$this->client->request('get',
"/api/v1/namespaces/{$namespace}/pods/{$name}/log"
,[
]
)
, 'readCoreV1NamespacedPodLog'
);
}
Kubernetes\API\Pod
class, need to add query parameter to readLog
function as third parameter.
there are query parameters in Kubernetes API Reference : https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12
I faced the same problem very recently. I needed to pass container
query param. For a full list of possible params check here. My temporary workaround was to extend the Pod:class
, create a new function and pass the query param I needed. My proposition though is to solve it properly, by using the guzzle ability to pass query params. So an example implementation could be
/**
* read log of the specified Pod
*
* @param $namespace
* @param $name
* @return string|mixed
*/
public function readLog(string $namespace = 'default',string $name, array $params =[])
{
return $this->parseResponse(
$this->client->request('get',
"/api/v1/namespaces/{$namespace}/pods/{$name}/log"
,[
'query' => $params
]
)
, 'readCoreV1NamespacedPodLog'
);
}
Dear @allansun, if you are open to contributions let me know to raise a PR that will propose this change.
Could you please provide some instructions on how to pull swagger.json after we pull master branch because it is not included. Do you have a manual flow for backward releases? If yes could you describe the steps to find a way to automate it? Thanks in advance, @allansun
@stafot @Veitor Thanks for the long waiting, I have 'almost' fully refactored the code generation logic for API part, all 'parameters' as described in the swagger files are correctly parsed and implemented into the generated code.
Your requested $queries can not be injected into the request
kubernetes-php-client/src/API/Pod.php
Lines 512 to 523 in 56d0a4e
If you noticed I've also managed to put the accepted parameters as PHPDoc, so you don't always have to go through to the Kubernetes documentation, a validator maybe implemented in future release, but it think at least it works now.
kubernetes-php-client/src/API/Pod.php
Lines 478 to 513 in 56d0a4e
Please notice I didn't re-tag the releases, instead I created
a patch to the latest stable release of each major version, you can reference to those specific composer version for the latest generated code. All new code generated from now on will follow the new code template.
Great @allansun, I will try it tomorrow and let you know. Thanks for addressed this.
Worked in my case!