Review Board 1.7.16


Use POST / DELETE to toggle bridge moh

Review Request #2911 - Created Oct. 15, 2013 and submitted

Paul Belanger
trunk
Reviewers
asterisk-dev
Asterisk
Another candidate for using POST / DELETE to toggle functionality.
local development box with python-ari

Diff revision 1 (Latest)

  1. trunk/res/res_ari_bridges.c: Loading...
  2. trunk/rest-api/api-docs/bridges.json: Loading...
trunk/res/res_ari_bridges.c
Revision 401007 New Change
[20] 487 lines
[+20] [+] static void ast_ari_remove_channel_from_bridge_cb(
488
	ast_free(args.channel_parse);
488
	ast_free(args.channel_parse);
489
	ast_free(args.channel);
489
	ast_free(args.channel);
490
	return;
490
	return;
491
}
491
}
492
/*!
492
/*!
493
 * \brief Parameter parsing callback for /bridges/{bridgeId}/mohStart.
493
 * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
494
 * \param get_params GET parameters in the HTTP request.
494
 * \param get_params GET parameters in the HTTP request.
495
 * \param path_vars Path variables extracted from the request.
495
 * \param path_vars Path variables extracted from the request.
496
 * \param headers HTTP headers.
496
 * \param headers HTTP headers.
497
 * \param[out] response Response to the HTTP request.
497
 * \param[out] response Response to the HTTP request.
498
 */
498
 */
[+20] [20] 37 lines
[+20] [+] static void ast_ari_moh_start_bridge_cb(
536
	default:
536
	default:
537
		if (200 <= code && code <= 299) {
537
		if (200 <= code && code <= 299) {
538
			is_valid = ast_ari_validate_void(
538
			is_valid = ast_ari_validate_void(
539
				response->message);
539
				response->message);
540
		} else {
540
		} else {
541
			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/mohStart\n", code);
541
			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
542
			is_valid = 0;
542
			is_valid = 0;
543
		}
543
		}
544
	}
544
	}
545

    
   
545

   
546
	if (!is_valid) {
546
	if (!is_valid) {
547
		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/mohStart\n");
547
		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
548
		ast_ari_response_error(response, 500,
548
		ast_ari_response_error(response, 500,
549
			"Internal Server Error", "Response validation failed");
549
			"Internal Server Error", "Response validation failed");
550
	}
550
	}
551
#endif /* AST_DEVMODE */
551
#endif /* AST_DEVMODE */
552

    
   
552

   
553
fin: __attribute__((unused))
553
fin: __attribute__((unused))
554
	return;
554
	return;
555
}
555
}
556
/*!
556
/*!
557
 * \brief Parameter parsing callback for /bridges/{bridgeId}/mohStop.
557
 * \brief Parameter parsing callback for /bridges/{bridgeId}/moh.
558
 * \param get_params GET parameters in the HTTP request.
558
 * \param get_params GET parameters in the HTTP request.
559
 * \param path_vars Path variables extracted from the request.
559
 * \param path_vars Path variables extracted from the request.
560
 * \param headers HTTP headers.
560
 * \param headers HTTP headers.
561
 * \param[out] response Response to the HTTP request.
561
 * \param[out] response Response to the HTTP request.
562
 */
562
 */
[+20] [20] 31 lines
[+20] [+] static void ast_ari_moh_stop_bridge_cb(
594
	default:
594
	default:
595
		if (200 <= code && code <= 299) {
595
		if (200 <= code && code <= 299) {
596
			is_valid = ast_ari_validate_void(
596
			is_valid = ast_ari_validate_void(
597
				response->message);
597
				response->message);
598
		} else {
598
		} else {
599
			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/mohStop\n", code);
599
			ast_log(LOG_ERROR, "Invalid error response %d for /bridges/{bridgeId}/moh\n", code);
600
			is_valid = 0;
600
			is_valid = 0;
601
		}
601
		}
602
	}
602
	}
603

    
   
603

   
604
	if (!is_valid) {
604
	if (!is_valid) {
605
		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/mohStop\n");
605
		ast_log(LOG_ERROR, "Response validation failed for /bridges/{bridgeId}/moh\n");
606
		ast_ari_response_error(response, 500,
606
		ast_ari_response_error(response, 500,
607
			"Internal Server Error", "Response validation failed");
607
			"Internal Server Error", "Response validation failed");
608
	}
608
	}
609
#endif /* AST_DEVMODE */
609
#endif /* AST_DEVMODE */
610

    
   
610

   
[+20] [20] 171 lines
[+20] [+] static struct stasis_rest_handlers bridges_bridgeId_removeChannel = {
782
	},
782
	},
783
	.num_children = 0,
783
	.num_children = 0,
784
	.children = {  }
784
	.children = {  }
785
};
785
};
786
/*! \brief REST handler for /api-docs/bridges.{format} */
786
/*! \brief REST handler for /api-docs/bridges.{format} */
787
static struct stasis_rest_handlers bridges_bridgeId_mohStart = {
787
static struct stasis_rest_handlers bridges_bridgeId_moh = {
788
	.path_segment = "mohStart",
788
	.path_segment = "moh",
789
	.callbacks = {
789
	.callbacks = {
790
		[AST_HTTP_POST] = ast_ari_moh_start_bridge_cb,
790
		[AST_HTTP_POST] = ast_ari_moh_start_bridge_cb,

    
   
791
		[AST_HTTP_DELETE] = ast_ari_moh_stop_bridge_cb,
791
	},
792
	},
792
	.num_children = 0,
793
	.num_children = 0,
793
	.children = {  }
794
	.children = {  }
794
};
795
};
795
/*! \brief REST handler for /api-docs/bridges.{format} */
796
/*! \brief REST handler for /api-docs/bridges.{format} */
796
static struct stasis_rest_handlers bridges_bridgeId_mohStop = {

   
797
	.path_segment = "mohStop",

   
798
	.callbacks = {

   
799
		[AST_HTTP_POST] = ast_ari_moh_stop_bridge_cb,

   
800
	},

   
801
	.num_children = 0,

   
802
	.children = {  }

   
803
};

   
804
/*! \brief REST handler for /api-docs/bridges.{format} */

   
805
static struct stasis_rest_handlers bridges_bridgeId_play = {
797
static struct stasis_rest_handlers bridges_bridgeId_play = {
806
	.path_segment = "play",
798
	.path_segment = "play",
807
	.callbacks = {
799
	.callbacks = {
808
		[AST_HTTP_POST] = ast_ari_play_on_bridge_cb,
800
		[AST_HTTP_POST] = ast_ari_play_on_bridge_cb,
809
	},
801
	},
[+20] [20] 15 lines
[+20] [+] static struct stasis_rest_handlers bridges_bridgeId = {
825
	.is_wildcard = 1,
817
	.is_wildcard = 1,
826
	.callbacks = {
818
	.callbacks = {
827
		[AST_HTTP_GET] = ast_ari_get_bridge_cb,
819
		[AST_HTTP_GET] = ast_ari_get_bridge_cb,
828
		[AST_HTTP_DELETE] = ast_ari_delete_bridge_cb,
820
		[AST_HTTP_DELETE] = ast_ari_delete_bridge_cb,
829
	},
821
	},
830
	.num_children = 6,
822
	.num_children = 5,
831
	.children = { &bridges_bridgeId_addChannel,&bridges_bridgeId_removeChannel,&bridges_bridgeId_mohStart,&bridges_bridgeId_mohStop,&bridges_bridgeId_play,&bridges_bridgeId_record, }
823
	.children = { &bridges_bridgeId_addChannel,&bridges_bridgeId_removeChannel,&bridges_bridgeId_moh,&bridges_bridgeId_play,&bridges_bridgeId_record, }
832
};
824
};
833
/*! \brief REST handler for /api-docs/bridges.{format} */
825
/*! \brief REST handler for /api-docs/bridges.{format} */
834
static struct stasis_rest_handlers bridges = {
826
static struct stasis_rest_handlers bridges = {
835
	.path_segment = "bridges",
827
	.path_segment = "bridges",
836
	.callbacks = {
828
	.callbacks = {
[+20] [20] 27 lines
trunk/rest-api/api-docs/bridges.json
Revision 401007 New Change
 
  1. trunk/res/res_ari_bridges.c: Loading...
  2. trunk/rest-api/api-docs/bridges.json: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.