comparison Plugins/OrthancCPlugin/OrthancCPlugin.h @ 913:3e43de893d88 plugins

POST, DELETE, PUT from Orthanc plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 20 Jun 2014 15:42:14 +0200
parents dcb2469f00f4
children 501880d76474
comparison
equal deleted inserted replaced
912:dcb2469f00f4 913:3e43de893d88
402 { 402 {
403 context->InvokeService(context, _OrthancPluginService_LogInfo, message); 403 context->InvokeService(context, _OrthancPluginService_LogInfo, message);
404 } 404 }
405 405
406 406
407
407 typedef struct 408 typedef struct
408 { 409 {
409 const char* pathRegularExpression; 410 const char* pathRegularExpression;
410 OrthancPluginRestCallback callback; 411 OrthancPluginRestCallback callback;
411 } _OrthancPluginRestCallback; 412 } _OrthancPluginRestCallback;
412
413 413
414 /** 414 /**
415 * @brief Register a REST callback. 415 * @brief Register a REST callback.
416 * 416 *
417 * This function registers a REST callback against a regular 417 * This function registers a REST callback against a regular
433 params.callback = callback; 433 params.callback = callback;
434 context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, &params); 434 context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, &params);
435 } 435 }
436 436
437 437
438
438 typedef struct 439 typedef struct
439 { 440 {
440 OrthancPluginRestOutput* output; 441 OrthancPluginRestOutput* output;
441 const char* answer; 442 const char* answer;
442 uint32_t answerSize; 443 uint32_t answerSize;
443 const char* mimeType; 444 const char* mimeType;
444 } _OrthancPluginAnswerBuffer; 445 } _OrthancPluginAnswerBuffer;
445
446 446
447 /** 447 /**
448 * @brief Answer to a REST request. 448 * @brief Answer to a REST request.
449 * 449 *
450 * This function answers to a REST request with the content of a memory buffer. 450 * This function answers to a REST request with the content of a memory buffer.
516 params.buffer = buffer; 516 params.buffer = buffer;
517 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerPngImage, &params); 517 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerPngImage, &params);
518 } 518 }
519 519
520 520
521
521 typedef struct 522 typedef struct
522 { 523 {
523 OrthancPluginMemoryBuffer* target; 524 OrthancPluginMemoryBuffer* target;
524 const char* instanceId; 525 const char* instanceId;
525 } _OrthancPluginGetDicomForInstance; 526 } _OrthancPluginGetDicomForInstance;
526
527 527
528 /** 528 /**
529 * @brief Retrieve a DICOM instance using its Orthanc identifier. 529 * @brief Retrieve a DICOM instance using its Orthanc identifier.
530 * 530 *
531 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM 531 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM
553 { 553 {
554 OrthancPluginMemoryBuffer* target; 554 OrthancPluginMemoryBuffer* target;
555 const char* uri; 555 const char* uri;
556 } _OrthancPluginRestApiGet; 556 } _OrthancPluginRestApiGet;
557 557
558 /**
559 * @brief Make a GET call to the built-in Orthanc REST API.
560 *
561 * Make a GET call to the built-in Orthanc REST API. The result to
562 * the query is stored into a newly allocated memory buffer.
563 *
564 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
565 * @param target The target memory buffer.
566 * @param uri The URI in the built-in Orthanc API.
567 * @return 0 if success, other value if error.
568 **/
558 ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiGet( 569 ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiGet(
559 OrthancPluginContext* context, 570 OrthancPluginContext* context,
560 OrthancPluginMemoryBuffer* target, 571 OrthancPluginMemoryBuffer* target,
561 const char* uri) 572 const char* uri)
562 { 573 {
565 params.uri = uri; 576 params.uri = uri;
566 return context->InvokeService(context, _OrthancPluginService_RestApiGet, &params); 577 return context->InvokeService(context, _OrthancPluginService_RestApiGet, &params);
567 } 578 }
568 579
569 580
581
582 typedef struct
583 {
584 OrthancPluginMemoryBuffer* target;
585 const char* uri;
586 const char* body;
587 uint32_t bodySize;
588 } _OrthancPluginRestApiPostPut;
589
590 /**
591 * @brief Make a POST call to the built-in Orthanc REST API.
592 *
593 * Make a POST call to the built-in Orthanc REST API. The result to
594 * the query is stored into a newly allocated memory buffer.
595 *
596 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
597 * @param target The target memory buffer.
598 * @param uri The URI in the built-in Orthanc API.
599 * @param body The body of the POST request.
600 * @param bodySize The size of the body.
601 * @return 0 if success, other value if error.
602 **/
603 ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiPost(
604 OrthancPluginContext* context,
605 OrthancPluginMemoryBuffer* target,
606 const char* uri,
607 const char* body,
608 uint32_t bodySize)
609 {
610 _OrthancPluginRestApiPostPut params;
611 params.target = target;
612 params.uri = uri;
613 params.body = body;
614 params.bodySize = bodySize;
615 return context->InvokeService(context, _OrthancPluginService_RestApiPost, &params);
616 }
617
618
619
620 /**
621 * @brief Make a DELETE call to the built-in Orthanc REST API.
622 *
623 * Make a DELETE call to the built-in Orthanc REST API.
624 *
625 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
626 * @param uri The URI to delete in the built-in Orthanc API.
627 * @return 0 if success, other value if error.
628 **/
629 ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiDelete(
630 OrthancPluginContext* context,
631 const char* uri)
632 {
633 return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri);
634 }
635
636
637
638 /**
639 * @brief Make a PUT call to the built-in Orthanc REST API.
640 *
641 * Make a PUT call to the built-in Orthanc REST API. The result to
642 * the query is stored into a newly allocated memory buffer.
643 *
644 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
645 * @param target The target memory buffer.
646 * @param uri The URI in the built-in Orthanc API.
647 * @param body The body of the PUT request.
648 * @param bodySize The size of the body.
649 * @return 0 if success, other value if error.
650 **/
651 ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiPut(
652 OrthancPluginContext* context,
653 OrthancPluginMemoryBuffer* target,
654 const char* uri,
655 const char* body,
656 uint32_t bodySize)
657 {
658 _OrthancPluginRestApiPostPut params;
659 params.target = target;
660 params.uri = uri;
661 params.body = body;
662 params.bodySize = bodySize;
663 return context->InvokeService(context, _OrthancPluginService_RestApiPut, &params);
664 }
665
666
570 #ifdef __cplusplus 667 #ifdef __cplusplus
571 } 668 }
572 #endif 669 #endif
573 670
574 671