Skip to content

Commit

Permalink
Jira API Configuration Add Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
cmenapace committed Apr 30, 2024
1 parent d6dc7f2 commit 6309907
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 11 additions & 0 deletions application/forms/Config/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ protected function assemble()
'label' => $this->translate('Scheme'),
'description' => $this->translate('Protocol used by Jira (http / https)'),
]
)->addElement(
'text',
'proxy',
[
'label' => $this->translate('Proxy Server'),
'description' => $this->translate(
'Proxy Server used to connect to Jira if needed, '
. 'format <hostname or IP>:<port>'
),
'required' => false,
]
);

$this->addElement(
Expand Down
11 changes: 9 additions & 2 deletions library/Jira/RestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ class RestApi

protected $enumCustomFields;

public function __construct($baseUrl, $username, $password)
protected $proxy;

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

Check failure on line 34 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Property Icinga\Module\Jira\RestApi::$proxy has no type specified.

public function __construct($baseUrl, $username, $password, $proxy)

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.

Check failure on line 36 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Method Icinga\Module\Jira\RestApi::__construct() has parameter $proxy with no type specified.
{
$this->username = $username;
$this->password = $password;
$this->baseUrlForLink = $baseUrl;
$this->baseUrl = \rtrim($baseUrl, '/') . '/rest';
$this->proxy = $proxy;
$this->serverInfo = $this->get('serverInfo')->getResult();
}

Expand All @@ -62,7 +65,7 @@ public static function fromConfig()
$user = $config->get('api', 'username');
$pass = $config->get('api', 'password');

$api = new static($url, $user, $pass);
$api = new static($url, $user, $pass, $proxy);

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Undefined variable: $proxy

Check failure on line 68 in library/Jira/RestApi.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Undefined variable: $proxy

return $api;
}
Expand Down Expand Up @@ -448,6 +451,10 @@ protected function request($method, $url, $body = null)
CURLOPT_SSL_VERIFYPEER => false,
);

if ($this->proxy) {
$opts[CURLOPT_PROXY] = $this->proxy;
}

curl_setopt_array($curl, $opts);
// TODO: request headers, validate status code

Expand Down

0 comments on commit 6309907

Please sign in to comment.