You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ra...@apache.org on 2021/02/12 21:36:41 UTC
[trafficcontrol] branch master updated: Add 'value' query parameter
to /parameters (#5508)
This is an automated email from the ASF dual-hosted git repository.
rawlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new a93fca4 Add 'value' query parameter to /parameters (#5508)
a93fca4 is described below
commit a93fca491db3746d5aaaeec41860d3acd0e63d23
Author: ocket8888 <oc...@apache.org>
AuthorDate: Fri Feb 12 16:36:24 2021 -0500
Add 'value' query parameter to /parameters (#5508)
* Add 'value' query parameter to /parameters
* Update Go client to use new query parameter
---
docs/source/api/v1/parameters.rst | 5 +++++
docs/source/api/v2/parameters.rst | 5 +++++
docs/source/api/v3/parameters.rst | 5 +++++
docs/source/api/v4/parameters.rst | 2 ++
traffic_ops/traffic_ops_golang/parameter/parameters.go | 10 ++++++----
traffic_ops/v4-client/parameter.go | 17 ++++-------------
6 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/docs/source/api/v1/parameters.rst b/docs/source/api/v1/parameters.rst
index 9b08884..3c9cc2d 100644
--- a/docs/source/api/v1/parameters.rst
+++ b/docs/source/api/v1/parameters.rst
@@ -40,6 +40,8 @@ Request Structure
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
| name | no | Filter :term:`Parameters` by :ref:`parameter-name` |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+ | value | no | Filter :term:`Parameters` by :ref:`parameter-value` |
+ +-------------+----------+---------------------------------------------------------------------------------------------------------------+
| orderby | no | Choose the ordering of the results - must be the name of one of the fields of the objects in the ``response`` |
| | | array |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
@@ -54,6 +56,9 @@ Request Structure
| | | defined to make use of ``page``. |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+.. versionadded:: ATCv6
+ The ``value`` query parameter was added to all API versions in ATC version 6.0.
+
.. code-block:: http
:caption: Request Example
diff --git a/docs/source/api/v2/parameters.rst b/docs/source/api/v2/parameters.rst
index 2e621f2..209c03b 100644
--- a/docs/source/api/v2/parameters.rst
+++ b/docs/source/api/v2/parameters.rst
@@ -40,6 +40,8 @@ Request Structure
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
| name | no | Filter :term:`Parameters` by :ref:`parameter-name` |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+ | value | no | Filter :term:`Parameters` by :ref:`parameter-value` |
+ +-------------+----------+---------------------------------------------------------------------------------------------------------------+
| orderby | no | Choose the ordering of the results - must be the name of one of the fields of the objects in the ``response`` |
| | | array |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
@@ -54,6 +56,9 @@ Request Structure
| | | defined to make use of ``page``. |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+.. versionadded:: ATCv6
+ The ``value`` query parameter was added to all API versions in ATC version 6.0.
+
.. code-block:: http
:caption: Request Example
diff --git a/docs/source/api/v3/parameters.rst b/docs/source/api/v3/parameters.rst
index a6d37cd..f716d7b 100644
--- a/docs/source/api/v3/parameters.rst
+++ b/docs/source/api/v3/parameters.rst
@@ -40,6 +40,8 @@ Request Structure
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
| name | no | Filter :term:`Parameters` by :ref:`parameter-name` |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+ | value | no | Filter :term:`Parameters` by :ref:`parameter-value` |
+ +-------------+----------+---------------------------------------------------------------------------------------------------------------+
| orderby | no | Choose the ordering of the results - must be the name of one of the fields of the objects in the ``response`` |
| | | array |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
@@ -54,6 +56,9 @@ Request Structure
| | | defined to make use of ``page``. |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+.. versionadded:: ATCv6
+ The ``value`` query parameter was added to all API versions in ATC version 6.0.
+
.. code-block:: http
:caption: Request Example
diff --git a/docs/source/api/v4/parameters.rst b/docs/source/api/v4/parameters.rst
index 627c3f6..2379593 100644
--- a/docs/source/api/v4/parameters.rst
+++ b/docs/source/api/v4/parameters.rst
@@ -40,6 +40,8 @@ Request Structure
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
| name | no | Filter :term:`Parameters` by :ref:`parameter-name` |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
+ | value | no | Filter :term:`Parameters` by :ref:`parameter-value` |
+ +-------------+----------+---------------------------------------------------------------------------------------------------------------+
| orderby | no | Choose the ordering of the results - must be the name of one of the fields of the objects in the ``response`` |
| | | array |
+-------------+----------+---------------------------------------------------------------------------------------------------------------+
diff --git a/traffic_ops/traffic_ops_golang/parameter/parameters.go b/traffic_ops/traffic_ops_golang/parameter/parameters.go
index 5449199..3b4d7af 100644
--- a/traffic_ops/traffic_ops_golang/parameter/parameters.go
+++ b/traffic_ops/traffic_ops_golang/parameter/parameters.go
@@ -77,10 +77,12 @@ func (v *TOParameter) NewReadObj() interface{} { return &tc.ParameterNullable{}
func (v *TOParameter) SelectQuery() string { return selectQuery() }
func (v *TOParameter) ParamColumns() map[string]dbhelpers.WhereColumnInfo {
return map[string]dbhelpers.WhereColumnInfo{
- ConfigFileQueryParam: dbhelpers.WhereColumnInfo{"p.config_file", nil},
- IDQueryParam: dbhelpers.WhereColumnInfo{"p.id", api.IsInt},
- NameQueryParam: dbhelpers.WhereColumnInfo{"p.name", nil},
- SecureQueryParam: dbhelpers.WhereColumnInfo{"p.secure", api.IsBool}}
+ ConfigFileQueryParam: {Column: "p.config_file"},
+ IDQueryParam: {Column: "p.id", Checker: api.IsInt},
+ NameQueryParam: {Column: "p.name"},
+ SecureQueryParam: {Column: "p.secure", Checker: api.IsBool},
+ ValueQueryParam: {Column: "p.value"},
+ }
}
func (v *TOParameter) UpdateQuery() string { return updateQuery() }
func (v *TOParameter) DeleteQuery() string { return deleteQuery() }
diff --git a/traffic_ops/v4-client/parameter.go b/traffic_ops/v4-client/parameter.go
index 4a80acc..27e4fb9 100644
--- a/traffic_ops/v4-client/parameter.go
+++ b/traffic_ops/v4-client/parameter.go
@@ -119,19 +119,10 @@ func (to *Session) GetParameterByNameAndConfigFile(name string, configFile strin
}
func (to *Session) GetParameterByNameAndConfigFileAndValueWithHdr(name, configFile, value string, header http.Header) ([]tc.Parameter, ReqInf, error) {
- params, reqInf, err := to.GetParameterByNameAndConfigFileWithHdr(name, configFile, header)
- if reqInf.StatusCode == http.StatusNotModified {
- return []tc.Parameter{}, reqInf, nil
- }
- if err != nil {
- return params, reqInf, err
- }
- for _, p := range params {
- if p.Value == value {
- return []tc.Parameter{p}, reqInf, err
- }
- }
- return nil, reqInf, err
+ URI := fmt.Sprintf("%s?name=%s&configFile=%s&value=%s", API_PARAMETERS, url.QueryEscape(name), url.QueryEscape(configFile), url.QueryEscape(value))
+ var data tc.ParametersResponse
+ reqInf, err := to.get(URI, header, &data)
+ return data.Response, reqInf, err
}
// GetParameterByNameAndConfigFileAndValue GETs a Parameter by the Parameter Name and ConfigFile and Value.