Asterisk - The Open Source Telephony Project  18.5.0
Functions
resource_endpoints.c File Reference

/api-docs/endpoints.{format} implementation- Endpoint resources More...

#include "asterisk.h"
#include "resource_endpoints.h"
#include "asterisk/astobj2.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_app.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/channel.h"
#include "asterisk/message.h"
Include dependency graph for resource_endpoints.c:

Go to the source code of this file.

Functions

void ast_ari_endpoints_get (struct ast_variable *headers, struct ast_ari_endpoints_get_args *args, struct ast_ari_response *response)
 Details for an endpoint. More...
 
void ast_ari_endpoints_list (struct ast_variable *headers, struct ast_ari_endpoints_list_args *args, struct ast_ari_response *response)
 List all endpoints. More...
 
void ast_ari_endpoints_list_by_tech (struct ast_variable *headers, struct ast_ari_endpoints_list_by_tech_args *args, struct ast_ari_response *response)
 List available endoints for a given endpoint technology. More...
 
void ast_ari_endpoints_send_message (struct ast_variable *headers, struct ast_ari_endpoints_send_message_args *args, struct ast_ari_response *response)
 Send a message to some technology URI or endpoint. More...
 
void ast_ari_endpoints_send_message_to_endpoint (struct ast_variable *headers, struct ast_ari_endpoints_send_message_to_endpoint_args *args, struct ast_ari_response *response)
 Send a message to some endpoint in a technology. More...
 
static int json_to_ast_variables (struct ast_ari_response *response, struct ast_json *json_variables, struct ast_variable **variables)
 
static void send_message (const char *to, const char *from, const char *body, struct ast_variable *variables, struct ast_ari_response *response)
 

Detailed Description

/api-docs/endpoints.{format} implementation- Endpoint resources

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file resource_endpoints.c.

Function Documentation

◆ ast_ari_endpoints_get()

void ast_ari_endpoints_get ( struct ast_variable headers,
struct ast_ari_endpoints_get_args args,
struct ast_ari_response response 
)

Details for an endpoint.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 153 of file resource_endpoints.c.

References ao2_cleanup, ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_endpoint_latest_snapshot(), ast_endpoint_snapshot_to_json(), NULL, RAII_VAR, ast_ari_endpoints_get_args::resource, stasis_app_get_sanitizer(), and ast_ari_endpoints_get_args::tech.

Referenced by ast_ari_endpoints_get_cb().

156 {
157  struct ast_json *json;
158  RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
159 
160  snapshot = ast_endpoint_latest_snapshot(args->tech, args->resource);
161  if (!snapshot) {
162  ast_ari_response_error(response, 404, "Not Found",
163  "Endpoint not found");
164  return;
165  }
166 
168  if (!json) {
170  return;
171  }
172 
173  ast_ari_response_ok(response, json);
174 }
struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot(const char *tech, const char *resource)
Retrieve the most recent snapshot for the endpoint with the given name.
#define NULL
Definition: resample.c:96
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
Definition: res_ari.c:276
A snapshot of an endpoint's state.
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
Definition: res_stasis.c:2264
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Abstract JSON element (object, array, string, int, ...).
struct ast_json * ast_endpoint_snapshot_to_json(const struct ast_endpoint_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_endpoint_snapshot.

◆ ast_ari_endpoints_list()

void ast_ari_endpoints_list ( struct ast_variable headers,
struct ast_ari_endpoints_list_args args,
struct ast_ari_response response 
)

List all endpoints.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 37 of file resource_endpoints.c.

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_endpoint_cache(), ast_endpoint_snapshot_to_json(), ast_endpoint_snapshot_type(), ast_json_array_append(), ast_json_array_create(), ast_json_ref(), ast_json_unref(), cache, NULL, RAII_VAR, stasis_app_get_sanitizer(), stasis_cache_dump(), and stasis_message_data().

Referenced by ast_ari_endpoints_list_cb().

40 {
42  RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
43  RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
44  struct ao2_iterator i;
45  void *obj;
46 
48  if (!cache) {
50  response, 500, "Internal Server Error",
51  "Message bus not initialized");
52  return;
53  }
54  ao2_ref(cache, +1);
55 
57  if (!snapshots) {
59  return;
60  }
61 
62  json = ast_json_array_create();
63  if (!json) {
65  return;
66  }
67 
68  i = ao2_iterator_init(snapshots, 0);
69  while ((obj = ao2_iterator_next(&i))) {
70  RAII_VAR(struct stasis_message *, msg, obj, ao2_cleanup);
71  struct ast_endpoint_snapshot *snapshot = stasis_message_data(msg);
72  struct ast_json *json_endpoint = ast_endpoint_snapshot_to_json(snapshot, stasis_app_get_sanitizer());
73 
74  if (!json_endpoint || ast_json_array_append(json, json_endpoint)) {
77  return;
78  }
79  }
81 
82  ast_ari_response_ok(response, ast_json_ref(json));
83 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct ao2_container * stasis_cache_dump(struct stasis_cache *cache, struct stasis_message_type *type)
Dump cached items to a subscription for the ast_eid_default entity.
Definition: stasis_cache.c:736
#define NULL
Definition: resample.c:96
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
Definition: res_ari.c:276
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
Definition: json.c:352
A snapshot of an endpoint's state.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
Definition: json.c:368
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
Definition: res_stasis.c:2264
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
struct ao2_container * cache
Definition: pbx_realtime.c:77
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Abstract JSON element (object, array, string, int, ...).
Generic container type.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
struct ast_json * ast_endpoint_snapshot_to_json(const struct ast_endpoint_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_endpoint_snapshot.
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().

◆ ast_ari_endpoints_list_by_tech()

void ast_ari_endpoints_list_by_tech ( struct ast_variable headers,
struct ast_ari_endpoints_list_by_tech_args args,
struct ast_ari_response response 
)

List available endoints for a given endpoint technology.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 85 of file resource_endpoints.c.

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_endpoint_cache(), ast_endpoint_find_by_id(), ast_endpoint_snapshot_to_json(), ast_endpoint_snapshot_type(), ast_json_array_append(), ast_json_array_create(), ast_json_ref(), ast_json_unref(), cache, NULL, RAII_VAR, stasis_app_get_sanitizer(), stasis_cache_dump(), stasis_message_data(), ast_endpoint_snapshot::tech, and ast_ari_endpoints_list_by_tech_args::tech.

Referenced by ast_ari_endpoints_list_by_tech_cb().

88 {
90  RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
91  RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
92  struct ast_endpoint *tech_endpoint;
93  struct ao2_iterator i;
94  void *obj;
95 
96  tech_endpoint = ast_endpoint_find_by_id(args->tech);
97  if (!tech_endpoint) {
98  ast_ari_response_error(response, 404, "Not Found",
99  "No Endpoints found - invalid tech %s", args->tech);
100  return;
101  }
102  ao2_ref(tech_endpoint, -1);
103 
105  if (!cache) {
107  response, 500, "Internal Server Error",
108  "Message bus not initialized");
109  return;
110  }
111  ao2_ref(cache, +1);
112 
114  if (!snapshots) {
116  return;
117  }
118 
119  json = ast_json_array_create();
120  if (!json) {
122  return;
123  }
124 
125  i = ao2_iterator_init(snapshots, 0);
126  while ((obj = ao2_iterator_next(&i))) {
127  RAII_VAR(struct stasis_message *, msg, obj, ao2_cleanup);
128  struct ast_endpoint_snapshot *snapshot = stasis_message_data(msg);
129  struct ast_json *json_endpoint;
130  int r;
131 
132  if (strcasecmp(args->tech, snapshot->tech) != 0) {
133  continue;
134  }
135 
136  json_endpoint = ast_endpoint_snapshot_to_json(snapshot, stasis_app_get_sanitizer());
137  if (!json_endpoint) {
138  continue;
139  }
140 
142  json, json_endpoint);
143  if (r != 0) {
146  return;
147  }
148  }
150  ast_ari_response_ok(response, ast_json_ref(json));
151 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct ast_endpoint * ast_endpoint_find_by_id(const char *id)
Finds the endpoint with the given tech[/resource] id.
struct ao2_container * stasis_cache_dump(struct stasis_cache *cache, struct stasis_message_type *type)
Dump cached items to a subscription for the ast_eid_default entity.
Definition: stasis_cache.c:736
#define NULL
Definition: resample.c:96
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
Definition: res_ari.c:276
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
Definition: json.c:352
A snapshot of an endpoint's state.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
Definition: json.c:368
struct stasis_message_sanitizer * stasis_app_get_sanitizer(void)
Get the Stasis message sanitizer for app_stasis applications.
Definition: res_stasis.c:2264
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
const ast_string_field tech
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
struct ao2_container * cache
Definition: pbx_realtime.c:77
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Abstract JSON element (object, array, string, int, ...).
Generic container type.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
struct ast_json * ast_endpoint_snapshot_to_json(const struct ast_endpoint_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_endpoint_snapshot.
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().

◆ ast_ari_endpoints_send_message()

void ast_ari_endpoints_send_message ( struct ast_variable headers,
struct ast_ari_endpoints_send_message_args args,
struct ast_ari_response response 
)

Send a message to some technology URI or endpoint.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 255 of file resource_endpoints.c.

References ast_ari_endpoints_send_message_parse_body(), ast_json_object_get(), ast_variables_destroy(), ast_ari_endpoints_send_message_args::body, ast_ari_endpoints_send_message_args::from, json_to_ast_variables(), NULL, send_message(), ast_ari_endpoints_send_message_args::to, and ast_ari_endpoints_send_message_args::variables.

Referenced by ast_ari_endpoints_send_message_cb().

258 {
259  struct ast_variable *variables = NULL;
260 
261  if (args->variables) {
262  struct ast_json *json_variables;
263 
265  json_variables = ast_json_object_get(args->variables, "variables");
266  if (json_variables
267  && json_to_ast_variables(response, json_variables, &variables)) {
268  return;
269  }
270  }
271 
272  send_message(args->to, args->from, args->body, variables, response);
273  ast_variables_destroy(variables);
274 }
int ast_ari_endpoints_send_message_parse_body(struct ast_json *body, struct ast_ari_endpoints_send_message_args *args)
Body parsing function for /endpoints/sendMessage.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
Structure for variables, used for configurations and for channel variables.
static int json_to_ast_variables(struct ast_ari_response *response, struct ast_json *json_variables, struct ast_variable **variables)
#define NULL
Definition: resample.c:96
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).
static void send_message(const char *to, const char *from, const char *body, struct ast_variable *variables, struct ast_ari_response *response)

◆ ast_ari_endpoints_send_message_to_endpoint()

void ast_ari_endpoints_send_message_to_endpoint ( struct ast_variable headers,
struct ast_ari_endpoints_send_message_to_endpoint_args args,
struct ast_ari_response response 
)

Send a message to some endpoint in a technology.

Parameters
headersHTTP headers
argsSwagger parameters
[out]responseHTTP response

Definition at line 276 of file resource_endpoints.c.

References ao2_ref, ast_ari_endpoints_send_message_to_endpoint_parse_body(), ast_ari_response_error(), ast_endpoint_latest_snapshot(), ast_json_object_get(), ast_str_to_lower(), ast_strdupa, ast_variables_destroy(), ast_ari_endpoints_send_message_to_endpoint_args::body, ast_ari_endpoints_send_message_to_endpoint_args::from, json_to_ast_variables(), NULL, ast_ari_endpoints_send_message_to_endpoint_args::resource, send_message(), ast_endpoint_snapshot::tech, ast_ari_endpoints_send_message_to_endpoint_args::tech, and ast_ari_endpoints_send_message_to_endpoint_args::variables.

Referenced by ast_ari_endpoints_send_message_to_endpoint_cb().

279 {
280  struct ast_variable *variables = NULL;
281  struct ast_endpoint_snapshot *snapshot;
282  char msg_to[128];
283  char *tech = ast_strdupa(args->tech);
284 
285  /* Really, we just want to know if this thing exists */
286  snapshot = ast_endpoint_latest_snapshot(args->tech, args->resource);
287  if (!snapshot) {
288  ast_ari_response_error(response, 404, "Not Found",
289  "Endpoint not found");
290  return;
291  }
292  ao2_ref(snapshot, -1);
293 
294  if (args->variables) {
295  struct ast_json *json_variables;
296 
298  json_variables = ast_json_object_get(args->variables, "variables");
299  if (json_variables
300  && json_to_ast_variables(response, json_variables, &variables)) {
301  return;
302  }
303  }
304 
305  snprintf(msg_to, sizeof(msg_to), "%s:%s", ast_str_to_lower(tech), args->resource);
306 
307  send_message(msg_to, args->from, args->body, variables, response);
308  ast_variables_destroy(variables);
309 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot(const char *tech, const char *resource)
Retrieve the most recent snapshot for the endpoint with the given name.
Structure for variables, used for configurations and for channel variables.
static int json_to_ast_variables(struct ast_ari_response *response, struct ast_json *json_variables, struct ast_variable **variables)
#define NULL
Definition: resample.c:96
int ast_ari_endpoints_send_message_to_endpoint_parse_body(struct ast_json *body, struct ast_ari_endpoints_send_message_to_endpoint_args *args)
Body parsing function for /endpoints/{tech}/{resource}/sendMessage.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static force_inline char * ast_str_to_lower(char *str)
Convert a string to all lower-case.
Definition: strings.h:1268
A snapshot of an endpoint's state.
const ast_string_field tech
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
Abstract JSON element (object, array, string, int, ...).
static void send_message(const char *to, const char *from, const char *body, struct ast_variable *variables, struct ast_ari_response *response)

◆ json_to_ast_variables()

static int json_to_ast_variables ( struct ast_ari_response response,
struct ast_json json_variables,
struct ast_variable **  variables 
)
static

Definition at line 234 of file resource_endpoints.c.

References ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_json_to_ast_variables(), AST_JSON_TO_AST_VARS_CODE_INVALID_TYPE, AST_JSON_TO_AST_VARS_CODE_OOM, AST_JSON_TO_AST_VARS_CODE_SUCCESS, ast_log, and AST_LOG_ERROR.

Referenced by ast_ari_endpoints_send_message(), and ast_ari_endpoints_send_message_to_endpoint().

235 {
236  enum ast_json_to_ast_vars_code res;
237 
238  res = ast_json_to_ast_variables(json_variables, variables);
239  switch (res) {
241  return 0;
243  ast_ari_response_error(response, 400, "Bad Request",
244  "Only string values in the 'variables' object allowed");
245  break;
248  break;
249  }
250  ast_log(AST_LOG_ERROR, "Unable to convert 'variables' in JSON body to Asterisk variables\n");
251 
252  return -1;
253 }
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
Conversion failed because invalid value type supplied.
Definition: json.h:1058
#define ast_log
Definition: astobj2.c:42
#define AST_LOG_ERROR
Definition: logger.h:290
Conversion successful.
Definition: json.h:1053
enum ast_json_to_ast_vars_code ast_json_to_ast_variables(struct ast_json *json_variables, struct ast_variable **variables)
Convert a ast_json list of key/value pair tuples into a ast_variable list.
Definition: json.c:797
Conversion failed because of allocation failure. (Out Of Memory)
Definition: json.h:1060
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
ast_json_to_ast_vars_code
Definition: json.h:1051

◆ send_message()

static void send_message ( const char *  to,
const char *  from,
const char *  body,
struct ast_variable variables,
struct ast_ari_response response 
)
static

Definition at line 176 of file resource_endpoints.c.

References ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_json_null(), ast_msg_alloc(), ast_msg_destroy(), ast_msg_send(), ast_msg_set_body(), ast_msg_set_from(), ast_msg_set_to(), ast_msg_set_var_outbound(), ast_strlen_zero, ast_ari_response::message, ast_variable::name, ast_variable::next, ast_ari_response::response_code, ast_ari_response::response_text, and ast_variable::value.

Referenced by ast_ari_endpoints_send_message(), and ast_ari_endpoints_send_message_to_endpoint().

177 {
178  struct ast_variable *current;
179  struct ast_msg *msg;
180  int res = 0;
181 
182  if (ast_strlen_zero(to)) {
183  ast_ari_response_error(response, 400, "Bad Request",
184  "To must be specified");
185  return;
186  }
187 
188  msg = ast_msg_alloc();
189  if (!msg) {
191  return;
192  }
193 
194  res |= ast_msg_set_from(msg, "%s", from);
195  res |= ast_msg_set_to(msg, "%s", to);
196 
197  if (!ast_strlen_zero(body)) {
198  res |= ast_msg_set_body(msg, "%s", body);
199  }
200 
201  for (current = variables; current; current = current->next) {
202  res |= ast_msg_set_var_outbound(msg, current->name, current->value);
203  }
204 
205  if (res) {
207  ast_msg_destroy(msg);
208  return;
209  }
210 
211  if (ast_msg_send(msg, to, from)) {
212  ast_ari_response_error(response, 404, "Not Found",
213  "Endpoint not found");
214  return;
215  }
216 
217  response->message = ast_json_null();
218  response->response_code = 202;
219  response->response_text = "Accepted";
220 }
struct ast_variable * next
int ast_msg_set_body(struct ast_msg *msg, const char *fmt,...)
Set the 'body' text of a message (in UTF-8)
Definition: message.c:476
struct ast_msg * ast_msg_alloc(void)
Allocate a message.
Definition: message.c:418
const ast_string_field to
Definition: message.c:249
Structure for variables, used for configurations and for channel variables.
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
Definition: res_ari.c:298
int ast_msg_set_to(struct ast_msg *msg, const char *fmt,...)
Set the 'to' URI of a message.
Definition: message.c:454
#define ast_strlen_zero(foo)
Definition: strings.h:52
int response_code
Definition: ari.h:98
int ast_msg_send(struct ast_msg *msg, const char *to, const char *from)
Send a msg directly to an endpoint.
Definition: message.c:1369
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
const ast_string_field body
Definition: message.c:249
const char * response_text
Definition: ari.h:102
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
Definition: res_ari.c:259
const ast_string_field from
Definition: message.c:249
struct ast_json * message
Definition: ari.h:93
int ast_msg_set_from(struct ast_msg *msg, const char *fmt,...)
Set the 'from' URI of a message.
Definition: message.c:465
int ast_msg_set_var_outbound(struct ast_msg *msg, const char *name, const char *value)
Set a variable on the message being sent to a message tech directly.
Definition: message.c:610
A message.
Definition: message.c:233
struct ast_msg * ast_msg_destroy(struct ast_msg *msg)
Destroy an ast_msg.
Definition: message.c:448