Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
c72bfb5
migration for new delivery_service_request table
dangogh Dec 19, 2017
d0ba6af
delivery service requests in deliveryservice/requests/.
dangogh Dec 26, 2017
c56716f
deliveryservice_request GET endpoint
dangogh Dec 26, 2017
8fcca1b
fix query param values
dangogh Dec 28, 2017
eb4a386
GetAuditName()
dangogh Dec 28, 2017
9ff4af7
no need to initialize lastUpdated
dangogh Dec 28, 2017
f39eb2e
first pass at ds request UI flow
mitchell852 Dec 28, 2017
1f90841
remove unneeded import
dangogh Dec 28, 2017
a081921
use CurrentUser as author
dangogh Dec 28, 2017
771aad7
fix lastUpdated on read
dangogh Dec 28, 2017
edf6999
fix GET .../:id
dangogh Dec 28, 2017
27f1cfe
use "draft" instead of "new" for new ds request
dangogh Dec 28, 2017
2b55229
hooks TP into ds request apis
mitchell852 Dec 28, 2017
1a46a1f
adds the ability to assign a ds request to yourself or unassign it
mitchell852 Dec 29, 2017
b492055
when a ds request is fulfilled, make sure it is assigned to the user …
mitchell852 Dec 29, 2017
1a3b217
add pending
dangogh Dec 29, 2017
5f0c831
adds db for Validate calls on ds request
dangogh Jan 4, 2018
65ea512
cleanup of log msgs. not using sprintf when reasonable
dangogh Jan 4, 2018
d94cafe
error if updating ds request results in conflict with another request
dangogh Jan 5, 2018
2b6da4f
just add authorid to struct
dangogh Jan 5, 2018
e049688
check for conflicting ds on insert
dangogh Jan 6, 2018
a3c9624
add deliveryservice_request validation
dangogh Jan 8, 2018
0b6ea5d
fix validation bug
dangogh Jan 8, 2018
cb677ec
hooks in pending status
mitchell852 Dec 29, 2017
dd94db1
fix time layout
dangogh Jan 8, 2018
33b2b80
allow ds requests/review process to be turned on/off globally in TP
mitchell852 Jan 8, 2018
1f7e729
uses xmlId instead of ds displayname for breadcrumb
mitchell852 Jan 8, 2018
84ca7fc
change import name to dsrequest
dangogh Jan 11, 2018
e1f1c73
modifies ds request flow per feedback
mitchell852 Jan 12, 2018
0808673
add created_at for ds request
dangogh Jan 12, 2018
5fe7395
adds the ability to see the changes associated with a ds request
mitchell852 Jan 16, 2018
fa5cb9c
order ds request by xml_id
dangogh Jan 16, 2018
e23d0a1
ORDER BY must occur after WHERE
dangogh Jan 17, 2018
0261f0f
adds ds request created column
mitchell852 Jan 17, 2018
46868cb
adds the ability to create ds requests to delete a ds
mitchell852 Jan 17, 2018
4805971
adds a showClosed checkbox to ds requests table and persists its valu…
mitchell852 Jan 17, 2018
e01e713
only show ds request vs ds diff if ds request is still "open"
mitchell852 Jan 18, 2018
379d2e9
provides a label for ds magic numbers (i.e. protocol, geoLimit, etc).…
mitchell852 Jan 18, 2018
5008325
provides a label for ds magic numbers (i.e. protocol, geoLimit, etc).…
mitchell852 Jan 18, 2018
fdad96c
adds tenancy check to ds request create/update/delete
dangogh Jan 17, 2018
2fceafe
adjust priv level
dangogh Jan 18, 2018
a90bad2
add tenancy checks to generic handlers
dangogh Jan 18, 2018
6b3faa4
use generic tenancy check
dangogh Jan 18, 2018
f88f18c
rename ds request to nullable
dangogh Jan 19, 2018
5e89cb0
temp workaround for test
dangogh Jan 22, 2018
9807086
add LastEditedBy fields
dangogh Jan 22, 2018
6cc0d4a
adjust imports
dangogh Jan 22, 2018
946de76
fix migration type
dangogh Jan 22, 2018
380a3e8
initial version of the dsrequests API test
dewrich Jan 22, 2018
f4b6893
migration for new delivery_service_request table
dangogh Dec 19, 2017
8dca6b8
delivery service requests in deliveryservice/requests/.
dangogh Dec 26, 2017
45b751a
deliveryservice_request GET endpoint
dangogh Dec 26, 2017
fa3f05c
fix query param values
dangogh Dec 28, 2017
2ec4372
GetAuditName()
dangogh Dec 28, 2017
2149ae0
no need to initialize lastUpdated
dangogh Dec 28, 2017
69e4168
first pass at ds request UI flow
mitchell852 Dec 28, 2017
0b79624
remove unneeded import
dangogh Dec 28, 2017
0853da1
use CurrentUser as author
dangogh Dec 28, 2017
a3e145e
fix lastUpdated on read
dangogh Dec 28, 2017
cff5df3
fix GET .../:id
dangogh Dec 28, 2017
fdb18f8
use "draft" instead of "new" for new ds request
dangogh Dec 28, 2017
0c1e414
hooks TP into ds request apis
mitchell852 Dec 28, 2017
955b048
adds the ability to assign a ds request to yourself or unassign it
mitchell852 Dec 29, 2017
aaf0be5
when a ds request is fulfilled, make sure it is assigned to the user …
mitchell852 Dec 29, 2017
5390f34
add pending
dangogh Dec 29, 2017
701d1d4
adds db for Validate calls on ds request
dangogh Jan 4, 2018
ea977c1
cleanup of log msgs. not using sprintf when reasonable
dangogh Jan 4, 2018
525bfa5
error if updating ds request results in conflict with another request
dangogh Jan 5, 2018
414b75f
just add authorid to struct
dangogh Jan 5, 2018
de8de74
check for conflicting ds on insert
dangogh Jan 6, 2018
2c0afa0
add deliveryservice_request validation
dangogh Jan 8, 2018
4fdda9b
fix validation bug
dangogh Jan 8, 2018
43ccd4b
hooks in pending status
mitchell852 Dec 29, 2017
1a8dd5e
fix time layout
dangogh Jan 8, 2018
f2ebede
allow ds requests/review process to be turned on/off globally in TP
mitchell852 Jan 8, 2018
8a118ab
uses xmlId instead of ds displayname for breadcrumb
mitchell852 Jan 8, 2018
996754a
change import name to dsrequest
dangogh Jan 11, 2018
fa4a265
modifies ds request flow per feedback
mitchell852 Jan 12, 2018
6e2274c
add created_at for ds request
dangogh Jan 12, 2018
38fb9a5
adds the ability to see the changes associated with a ds request
mitchell852 Jan 16, 2018
46c135d
order ds request by xml_id
dangogh Jan 16, 2018
71898ee
ORDER BY must occur after WHERE
dangogh Jan 17, 2018
113c4ac
adds ds request created column
mitchell852 Jan 17, 2018
f4f3544
adds the ability to create ds requests to delete a ds
mitchell852 Jan 17, 2018
f0cd89e
adds a showClosed checkbox to ds requests table and persists its valu…
mitchell852 Jan 17, 2018
e2589ae
only show ds request vs ds diff if ds request is still "open"
mitchell852 Jan 18, 2018
04adbeb
provides a label for ds magic numbers (i.e. protocol, geoLimit, etc).…
mitchell852 Jan 18, 2018
f19f85a
provides a label for ds magic numbers (i.e. protocol, geoLimit, etc).…
mitchell852 Jan 18, 2018
c3bd5f7
adds tenancy check to ds request create/update/delete
dangogh Jan 17, 2018
b4ec46c
adjust priv level
dangogh Jan 18, 2018
c93c1a4
add tenancy checks to generic handlers
dangogh Jan 18, 2018
722fbf0
use generic tenancy check
dangogh Jan 18, 2018
676f8ac
rename ds request to nullable
dangogh Jan 19, 2018
db64bdb
temp workaround for test
dangogh Jan 22, 2018
e4c2b27
add LastEditedBy fields
dangogh Jan 22, 2018
ccfc6be
renamed for consistency
dewrich Jan 22, 2018
4a96861
refactored for consistency
dewrich Jan 22, 2018
eae4716
refactored validation rules to avoid panics
dewrich Jan 22, 2018
5c6e10a
added non-nil fields for the TO Client
dewrich Jan 22, 2018
ac9bec2
removed date stamps for testing
dewrich Jan 22, 2018
68a5525
formatted which removed import
dewrich Jan 22, 2018
410a3cf
fixed merge issues
dewrich Jan 22, 2018
e8a2a14
updated for tenancy test data
dewrich Jan 22, 2018
39d04dd
Update README to add doc status, and readthedocs links
Jan 5, 2018
5fea22f
Update README to better use badges
Jan 5, 2018
9b7171a
Update README to fix header
Jan 5, 2018
93f1894
Update README - remove double //
Jan 5, 2018
1f4d715
updates ds field descriptions in the docs
mitchell852 Jan 23, 2018
0a85322
fixes broken rst table
mitchell852 Jan 23, 2018
fc6c477
fix alert test
dangogh Jan 23, 2018
77f62cb
Fix TO not_a_parent server exclusion
rob05c Jan 23, 2018
df672cb
get tenantid from json blob
dangogh Jan 22, 2018
e1d6e28
return after handling errors
dangogh Jan 23, 2018
06de7ab
close results; ensure err available on defer
dangogh Jan 23, 2018
3d977e7
finish request validation
dangogh Jan 23, 2018
7e6ed8e
fix JSON id for tenant
dangogh Jan 24, 2018
1a0d995
centralize info from deliveryservice
dangogh Jan 24, 2018
862bdf1
query by xmlid; response key lowcased
dangogh Jan 24, 2018
6bf45c9
remove validation for authorID -- not needed
dangogh Jan 25, 2018
929dbbd
rename column
dangogh Jan 25, 2018
a955c1e
change request to deliveryservice; fix api test
dangogh Jan 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
under the License.
-->

Build: [![Build Status](https://builds.apache.org/buildStatus/icon?job=incubator-trafficcontrol-master-build)](https://builds.apache.org/view/Incubator%20Projects/job/incubator-trafficcontrol-master-build/)
[![Build Status](https://builds.apache.org/buildStatus/icon?job=incubator-trafficcontrol-master-build)](https://builds.apache.org/view/Incubator%20Projects/job/incubator-trafficcontrol-master-build/) [![Documentation Status](https://readthedocs.org/projects/traffic-control-cdn/badge/?version=latest)](http://traffic-control-cdn.readthedocs.io/en/latest/?badge=latest)

Apache Traffic Control (incubating) is an Open Source implementation of a Content Delivery Network.

#### Documentation
* [Intro](http://trafficcontrol.apache.org/docs/latest/index.html)
* [CDN Basics](http://trafficcontrol.apache.org/docs/latest/basics/index.html)
* [Traffic Control Overview](http://trafficcontrol.apache.org/docs/latest/overview/index.html)
* [Administrator's Guide](http://trafficcontrol.apache.org/docs/latest/admin/index.html)
* [Developer's Guide](http://trafficcontrol.apache.org/docs/latest/development/index.html)
* [Intro](http://traffic-control-cdn.readthedocs.io/en/latest/index.html)
* [CDN Basics](http://traffic-control-cdn.readthedocs.io/en/latest/basics/index.html)
* [Traffic Control Overview](http://traffic-control-cdn.readthedocs.io/en/latest/overview/index.html)
* [Administrator's Guide](http://traffic-control-cdn.readthedocs.io/en/latest/admin/index.html)
* [Developer's Guide](http://traffic-control-cdn.readthedocs.io/en/latest/development/index.html)

####Questions, Comments, Bugs and More
* [Frequently Asked Questions](http://trafficcontrol.apache.org/docs/latest/faq/index.html)
#### Questions, Comments, Bugs and More
* [Frequently Asked Questions](http://traffic-control-cdn.readthedocs.io/en/latest/faq/index.html)
* [Found a bug or file a feature request](https://github.com/apache/incubator-trafficcontrol/issues)
* [Subscribe to our users list](mailto:users-subscribe@trafficcontrol.incubator.apache.org)
* [Subscribe to our dev list](mailto:dev-subscribe@trafficcontrol.incubator.apache.org)
Expand Down
130 changes: 76 additions & 54 deletions docs/source/admin/traffic_ops/using.rst

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/go-tc/alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ func TestGetHandleErrorFunc(t *testing.T) {
}
body := `{"alerts":[{"text":"this is an error","level":"error"}]}`

errHandler := GetHandleErrorFunc(w, r)
errHandler(fmt.Errorf("this is an error"), http.StatusBadRequest)
errHandler := GetHandleErrorsFunc(w, r)
errHandler(http.StatusBadRequest, fmt.Errorf("this is an error"))
if w.Body.String() != body {
t.Error("Expected body", body, "got", w.Body.String())
}

w = httptest.NewRecorder()
body = `{"alerts":[]}`

errHandler = GetHandleErrorFunc(w, r)
errHandler(nil, http.StatusBadRequest)
errHandler = GetHandleErrorsFunc(w, r)
errHandler(http.StatusBadRequest, nil)
if w.Body.String() != body {
t.Error("Expected body", body, "got", w.Body.String())
}
Expand Down
55 changes: 55 additions & 0 deletions lib/go-tc/deliveryservice_requests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package tc

/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import (
"encoding/json"
)

// DeliveryServiceRequestNullable is used as part of the workflow to create,
// modify, or delete a delivery service.
type DeliveryServiceRequest struct {
AssigneeID int `json:"assigneeId,omitempty" db:"assignee_id"`
Assignee string `json:"assignee,omitempty"`
AuthorID int `json:"authorId" db:"author_id"`
Author string `json:"author"`
ChangeType string `json:"changeType" db:"change_type"`
CreatedAt string `json:"createdAt,omitempty" db:"created_at"`
ID int `json:"id" db:"id"`
LastEditedBy string `json:"lastEditedBy"`
LastEditedByID int `json:"lastEditedById" db:"last_edited_by_id"`
LastUpdated string `json:"lastUpdated,omitempty" db:"last_updated"`
Deliveryservice json.RawMessage `json:"deliveryservice" db:"deliveryservice"`
Status string `json:"status" db:"status"`
}

// DeliveryServiceRequestNullable is used as part of the workflow to create,
// modify, or delete a delivery service.
type DeliveryServiceRequestNullable struct {
AssigneeID *int `json:"assigneeId,omitempty" db:"assignee_id"`
Assignee *string `json:"assignee,omitempty"`
AuthorID int `json:"authorId" db:"author_id"`
Author string `json:"author"`
ChangeType string `json:"changeType" db:"change_type"`
CreatedAt Time `json:"createdAt" db:"created_at"`
ID int `json:"id" db:"id"`
LastEditedBy string `json:"lastEditedBy"`
LastEditedByID int `json:"lastEditedById" db:"last_edited_by_id"`
LastUpdated Time `json:"lastUpdated" db:"last_updated"`
Deliveryservice json.RawMessage `json:"deliveryservice" db:"deliveryservice"`
Status string `json:"status" db:"status"`
XMLID string `json:"-" db:"xml_id"`
}
2 changes: 1 addition & 1 deletion lib/go-tc/deliveryservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type DeliveryService struct {
RangeRequestHandling int `json:"rangeRequestHandling"`
EdgeHeaderRewrite string `json:"edgeHeaderRewrite"`
MidHeaderRewrite string `json:"midHeaderRewrite"`
TenantID int `json:"tenant_id,omitempty"`
TenantID int `json:"tenantId,omitempty"`
TRResponseHeaders string `json:"trResponseHeaders"`
RegexRemap string `json:"regexRemap"`
CacheURL string `json:"cacheurl"`
Expand Down
5 changes: 2 additions & 3 deletions lib/go-tc/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package tc

import (
"database/sql/driver"
"fmt"
"strings"
"time"
)
Expand All @@ -32,7 +31,7 @@ type Time struct {
}

// TimeLayout is the format used in lastUpdated fields in Traffic Ops
const TimeLayout = "2006-01-02 15:04:05+00"
const TimeLayout = "2006-01-02 15:04:05-07"

// Scan implements the database/sql Scanner interface.
func (jt *Time) Scan(value interface{}) error {
Expand All @@ -53,7 +52,7 @@ func (t *Time) MarshalJSON() ([]byte, error) {
if t.Time.IsZero() {
return []byte("null"), nil
}
return []byte(fmt.Sprintf("\"%s\"", t.Time.Format(TimeLayout))), nil
return []byte(`"` + t.Time.Format(TimeLayout) + `"`), nil
}

// UnmarshalJSON reads time from JSON into Time var
Expand Down
50 changes: 50 additions & 0 deletions traffic_ops/app/db/migrations/20171226000000_add-ds-request.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

-- +goose Up
-- SQL in section 'Up' is executed when this migration is applied
CREATE TYPE workflow_states AS ENUM ('draft', 'submitted', 'rejected', 'pending', 'complete');
CREATE TYPE change_types AS ENUM ('create', 'update', 'delete');

CREATE TABLE deliveryservice_request (
assignee_id bigint,
author_id bigint NOT NULL,
change_type change_types NOT NULL,
created_at timestamp WITH time zone NOT NULL DEFAULT now(),
id bigserial primary key NOT NULL,
last_edited_by_id bigint NOT NULL,
last_updated timestamp WITH time zone NOT NULL DEFAULT now(),
deliveryservice jsonb NOT NULL,
status workflow_states NOT NULL
);

ALTER TABLE deliveryservice_request
ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES tm_user(id) ON DELETE CASCADE;

ALTER TABLE deliveryservice_request
ADD CONSTRAINT fk_assignee FOREIGN KEY (assignee_id) REFERENCES tm_user(id) ON DELETE SET NULL;

ALTER TABLE deliveryservice_request
ADD CONSTRAINT fk_last_edited_by FOREIGN KEY (last_edited_by_id) REFERENCES tm_user(id) ON DELETE CASCADE;

CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON deliveryservice_request FOR EACH ROW EXECUTE PROCEDURE on_update_current_timestamp_last_updated();

-- +goose Down
-- SQL section 'Down' is executed when this migration is rolled back
DROP TABLE deliveryservice_request;

DROP TYPE change_types;

DROP TYPE workflow_states;
4 changes: 4 additions & 0 deletions traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,7 @@ sub cachegroup_profiles {
port => $self->profile_param_value( $pid, 'parent.config', 'port', undef ),
use_ip_address => $self->profile_param_value( $pid, 'parent.config', 'use_ip_address', 0 ),
rank => $self->profile_param_value( $pid, 'parent.config', 'rank', 1 ),
not_a_parent => $self->profile_param_value( $pid, 'parent.config', 'not_a_parent', 'false' ),
};
}
}
Expand Down Expand Up @@ -2235,6 +2236,9 @@ sub parent_data {
foreach my $prefix ( keys %deliveryservices ) {
foreach my $row ( @{ $deliveryservices{$prefix} } ) {
my $pid = $row->profile->id;
if ( $profile_cache{$pid}->{not_a_parent} ne 'false' ) {
next;
}
my $ds_domain = $profile_cache{$pid}->{domain_name};
my $weight = $profile_cache{$pid}->{weight};
my $port = $profile_cache{$pid}->{port};
Expand Down
135 changes: 135 additions & 0 deletions traffic_ops/client/deliveryservice_requests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package client

import (
"encoding/json"
"net"
"net/http"

"github.com/apache/incubator-trafficcontrol/lib/go-log"
"github.com/apache/incubator-trafficcontrol/lib/go-tc"
)

const (
API_DS_REQUESTS = "/api/1.3/deliveryservice_requests"
)

// Create a Delivery Service Request
func (to *Session) CreateDeliveryServiceRequest(dsr tc.DeliveryServiceRequest) (tc.Alerts, ReqInf, error) {

var remoteAddr net.Addr
reqBody, err := json.Marshal(dsr)
log.Debugln("Request: ", string(reqBody))
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
return tc.Alerts{}, reqInf, err
}
resp, remoteAddr, err := to.request(http.MethodPost, API_DS_REQUESTS, reqBody)
if err != nil {
return tc.Alerts{}, reqInf, err
}
defer resp.Body.Close()
var alerts tc.Alerts
err = json.NewDecoder(resp.Body).Decode(&alerts)
return alerts, reqInf, nil
}

/*
// Update a DeliveryServiceRequest by ID
func (to *Session) UpdateDeliveryServiceRequestByID(id int, dsr tc.DeliveryServiceRequest) (tc.Alerts, ReqInf, error) {

var remoteAddr net.Addr
reqBody, err := json.Marshal(dsr)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
return tc.Alerts{}, reqInf, err
}
route := fmt.Sprintf("%s/%d", API_DS_REQUESTS, id)
resp, remoteAddr, err := to.request(http.MethodPut, route, reqBody)
if err != nil {
return tc.Alerts{}, reqInf, err
}
defer resp.Body.Close()
var alerts tc.Alerts
err = json.NewDecoder(resp.Body).Decode(&alerts)
return alerts, reqInf, nil
}

// Returns a list of DeliveryServiceRequests
func (to *Session) GetDeliveryServiceRequests() ([]tc.DeliveryServiceRequest, ReqInf, error) {
resp, remoteAddr, err := to.request(http.MethodGet, API_DS_REQUESTS, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
return nil, reqInf, err
}
defer resp.Body.Close()

var data tc.DeliveryServiceRequestsResponse
err = json.NewDecoder(resp.Body).Decode(&data)
return data.Response, reqInf, nil
}

// GET a DeliveryServiceRequest by the DeliveryServiceRequest id
func (to *Session) GetDeliveryServiceRequestByID(id int) ([]tc.DeliveryServiceRequest, ReqInf, error) {
route := fmt.Sprintf("%s/%d", API_DS_REQUESTS, id)
resp, remoteAddr, err := to.request(http.MethodGet, route, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
return nil, reqInf, err
}
defer resp.Body.Close()

var data tc.DeliveryServiceRequestsResponse
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
return nil, reqInf, err
}

return data.Response, reqInf, nil
}

// GET a DeliveryServiceRequest by the DeliveryServiceRequest assignee
func (to *Session) GetDeliveryServiceRequestByAssignee(assignee string) ([]tc.DeliveryServiceRequest, ReqInf, error) {
url := fmt.Sprintf("%s/assignee/%s", API_DS_REQUESTS, assignee)
resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
return nil, reqInf, err
}
defer resp.Body.Close()

var data tc.DeliveryServiceRequestsResponse
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
return nil, reqInf, err
}

return data.Response, reqInf, nil
}

// DELETE a DeliveryServiceRequest by DeliveryServiceRequest assignee
func (to *Session) DeleteDeliveryServiceRequestByAssignee(assignee string) (tc.Alerts, ReqInf, error) {
route := fmt.Sprintf("%s/assignee/%s", API_DS_REQUESTS, assignee)
resp, remoteAddr, err := to.request(http.MethodDelete, route, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
return tc.Alerts{}, reqInf, err
}
defer resp.Body.Close()
var alerts tc.Alerts
err = json.NewDecoder(resp.Body).Decode(&alerts)
return alerts, reqInf, nil
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
limitations under the License.
*/

package api
package config

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"

log "github.com/apache/incubator-trafficcontrol/lib/go-log"
"github.com/kelseyhightower/envconfig"
)

Expand Down Expand Up @@ -118,3 +119,28 @@ func LoadConfig(confPath string) (Config, error) {

return cfg, err
}

// ErrorLog - critical messages
func (c Config) ErrorLog() log.LogLocation {
return log.LogLocation(c.Default.Log.Error)
}

// WarningLog - warning messages
func (c Config) WarningLog() log.LogLocation {
return log.LogLocation(c.Default.Log.Warning)
}

// InfoLog - information messages
func (c Config) InfoLog() log.LogLocation {
return log.LogLocation(c.Default.Log.Info)
}

// DebugLog - troubleshooting messages
func (c Config) DebugLog() log.LogLocation {
return log.LogLocation(c.Default.Log.Debug)
}

// EventLog - access.log high level transactions
func (c Config) EventLog() log.LogLocation {
return log.LogLocation(c.Default.Log.Event)
}
Loading