blob: b7da6caa2791b9d945da6fbe5cf4a8ca62e4097a [file] [log] [blame]
Henry Yuc10f7fc2017-07-26 13:42:08 -04001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Henry Yuc10f7fc2017-07-26 13:42:08 -04003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.restconf.api;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
19
20import javax.ws.rs.core.Response;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
23
24/**
25 * Output of a RESTCONF RPC.
26 */
27public class RestconfRpcOutput {
28 private Response.Status status;
29 private ObjectNode output;
30 private String reasonPhrase;
31
32
33 /**
34 * Default constructor.
35 */
36 public RestconfRpcOutput() {
37
38 }
39
40 /**
41 * Instantiates a new RPC output object.
42 *
43 * @param s RPC execution status
44 * @param d RPC output in JSON format
45 */
46 public RestconfRpcOutput(Response.Status s, ObjectNode d) {
47 this.status = s;
48 this.output = d;
49 }
50
51 /**
52 * Sets the RPC execution status.
53 *
54 * @param s status
55 */
56 public void status(Response.Status s) {
57 this.status = s;
58 }
59
60 /**
61 * Sets the failure reason message for the RPC execution.
62 *
63 * @param s failure reason
64 */
65 public void reason(String s) {
66 this.reasonPhrase = s;
67 }
68
69 /**
70 * Returns the failure reason.
71 *
72 * @return failure reason
73 */
74 public String reason() {
75 return this.reasonPhrase;
76 }
77
78 /**
79 * Sets the RPC output.
80 *
81 * @param d RPC output in JSON format
82 */
83 public void output(ObjectNode d) {
84 this.output = d;
85 }
86
87 /**
88 * Returns the RPC execution status.
89 *
90 * @return status
91 */
92 public Response.Status status() {
93 return this.status;
94 }
95
96 /**
97 * Returns the RPC output in JSON format.
98 *
99 * @return output
100 */
101 public ObjectNode output() {
102 return this.output;
103 }
104
105 @Override
106 public String toString() {
107 return toStringHelper(this)
108 .add("status", status)
109 .add("reason", reasonPhrase)
110 .add("output", output)
111 .toString();
112 }
113}