-
Notifications
You must be signed in to change notification settings - Fork 8
/
service.rest.html
7321 lines (7283 loc) · 823 KB
/
service.rest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>137 REST Management Service Specification - OSGi Compendium 8</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
<link rel="home" href="index.html" title="OSGi Compendium" />
<link rel="up" href="index.html" title="OSGi Compendium" />
<link rel="prev" href="service.namespaces.html" title="135 Common Namespaces Specification" />
<link rel="next" href="service.async.html" title="138 Asynchronous Service Specification" />
<meta name="Section-title" content="137 REST Management Service Specification" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="images/favicon.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="css/custom.css" />
<link rel="stylesheet" type="text/css" href="css/github.css" />
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin" /><script type="text/javascript" src="js/highlight.pack.js"></script><script type="text/javascript" src="js/main.js"></script></head>
<body>
<div id="fullbody">
<div id="header">
<div class="menu-top-container"></div>
<div id="shadow-block"><a class="logo" href="index.html"><img src="images/OSGi.svg" alt="OSGi Working Group Documentation" /><h1>OSGi Compendium Release 8</h1></a></div>
</div>
<div id="mobile-menu-icon">⋮</div>
<div id="column-two">
<div id="content">
<div id="scrollable">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<td width="20%" align="left"><a accesskey="p" href="service.namespaces.html">Prev</a>
</td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="service.async.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="chapter">
<div xmlns="" class="titlepage">
<div>
<div>
<h1 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="service.rest"></a><span xmlns="" class="number">137</span> REST Management Service Specification
</h1>
</div>
<div>
<p xmlns="http://www.w3.org/1999/xhtml" class="releaseinfo"><a xmlns="" class="xref" href="service.rest.html#org.osgi.service.rest" title="137.10 org.osgi.service.rest">Version 1.0</a></p>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h2 xmlns="http://www.w3.org/1999/xhtml" class="title" style="clear: both"><a xmlns="" class="anchor" id="d0e80494"></a><span xmlns="" class="number">137.1</span> Introduction
</h2>
</div>
</div>
</div>
<p>Cloud computing is a continuing trend in the IT industry. Due to its
service model which embraces dynamism as opposed to masking it, OSGi
appears to be an ideal base for building scalable and dependable
applications for the cloud where changes in the deployment, network
topology, and service availability are the norm rather than the exception.
One of the possible scenarios for OSGi to be successfully applied to cloud
computing is using it in a Platform as a Service (PaaS) spirit. Users
write their bundles and can deploy them to a provided OSGi instance
running in the cloud. This, however, requires the platform provider to
expose the OSGi management API to the end user and make them available
through a network protocol. One of the popular approaches in cloud
computing to remote communication is the use of RESTful web
services.
</p>
<p>Representational State Transfer (REST) is the architectural style of
the world wide web. It can be described as a set of constraints that
govern the interactions between the main components of the Internet.
Recently, REST style interaction has gained popularity as a architecture
for web services (RESTful web services), mainly to overcome the perceived
complexity and verbosity of SOAP-based web services. This specification
describes a REST interface for framework management, client-side Java and
JavaScript APIs, and an extension mechanism through which other bundles
can contribute their own RESTful management APIs and make them
discoverable by clients.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80501"></a><span xmlns="" class="number">137.1.1</span> Essentials
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p><span class="emphasis"><em>Client-Server</em></span> - A separation of concern
between the entity responsible for the user-interaction (client) and
the other entity (server) responsible for data storage. For
instance, in the original world wide web the browser is the client
rendering and presenting the content delivered by one or more web
servers. As a result, web content becomes more portable and content
providers more scalable.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>Stateless</em></span> - State is entirely kept at the
client side. Therefore, every request must contain all state
required for the server to accomplish the transaction and deliver
content. The main rationale behind this design constraint is to
again improve the scalability since in a pure stateless design the
server resources are not burdened with maintaining any client state.
Another perceived advantage is that the failure models of stateless
interactions is simpler and fault tolerance easier to
achieve.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>Cacheable</em></span> - Content marked as cacheable
can be temporarily stored and used to immediately answer future
equivalent requests and improve efficiency and reduce network
utilization and access latencies. Due to the end-to-end principle,
caches can be placed where necessary, e.g., at the client
(forward-proxy), at the server side (backward-proxy), or somewhere
in-between for example in a content delivery network. Content marked
as non-cacheable must be freshly retrieved with every request even
in the presence of caches.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>Layered</em></span> - Layering introduces natural
boundaries to coupling since every layer only accesses the services
provided by the lower layer and provides services to the next higher
layer.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>Uniform Interface</em></span> - Generality of
component interfaces provides a natural decoupling of implementation
and interface. REST furthermore encourages the separation of
identifiable resources (addressing) and their representation
(content delivery).
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80530"></a><span xmlns="" class="number">137.1.2</span> Entities
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p><span class="emphasis"><em>Resource</em></span> - A resource is an abstract
piece of information that can be addressed by a resource identifier.
The mapping of a resource to a concrete set of entities can vary
over time.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>Representation</em></span> - A representation is a
sequence of bytes plus associated meta-data that describe the state
of a resource. The data format of a representation is called the
media-type. Every concrete representation of a resource is just one
of arbitrarily many possible representations. The selection of a
concrete representation of a resource can be made according to the
media types supported by both the client and the server.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>REST Management Service</em></span> - The management
service exposes a REST API for remotely managing an OSGi framework
through the network in a lightweight and portable fashion.
</p>
</li>
<li class="listitem">
<p><span class="emphasis"><em>Client</em></span> - The client is a machine using
the management service by issuing REST requests through the network.
It can do so either directly or indirectly, i.e., through
client-side libraries using the REST calls internally.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80554"></a><span xmlns="" class="number">137.1.3</span> Synopsis
</h3>
</div>
</div>
</div>
<p>The manageable entities of an OSGi framework are mapped to
resources accessible through resource identifiers. These identifiers are
relative to the (usually externally accessible) root URL of the
management service. Clients can either discover this root URL or receive
it through configuration. Subsequently, a client is able to introspect
the state of the framework and perform management operations.
</p>
<p>The internal state of a framework resource is expressed and
transmitted as a representation. The format of the representation is
subject to a mutual agreement between client and management service
regarding media types commonly supported by both endpoints. This
specification describes two representation formats: JSON and XML.
</p>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h2 xmlns="http://www.w3.org/1999/xhtml" class="title" style="clear: both"><a xmlns="" class="anchor" id="d0e80561"></a><span xmlns="" class="number">137.2</span> Interacting with the REST Management Service
</h2>
</div>
</div>
</div>
<p>The REST Management Service is not a traditional OSGi service and it
does not appear in the service registry. Its purpose is to expose a
management interface to clients which can perform operations on the
framework through a network connection. Therefore, it is ideally suited
for situations where the user of an OSGi framework does not have direct
access to the machine it is running on, a typical situation in
Infrastructure as a Service (IaaS) or Platform as a Service (PaaS).
However, even in other domains having a lightweight and easily accessible
management solution can be of benefit, e.g., for embedded devices. The
advantage of REST is that it uses HTTP and therefore does usually not
interfere with firewalls. Furthermore, the REST format is easily
embeddable into client-side scripting technologies like JavaScript and can
be consumed in web browsers.
</p>
<p>Much of the value of the REST Management Service lies in client-side
libraries which can use the REST protocol and interact with the OSGi
framework through the Management Service. Therefore, this specification
contains API for two clients, a <a xmlns="" class="link" href="service.rest.html#org.osgi.service.rest.client" title="137.11 org.osgi.service.rest.client">Java Client API</a> and a <a xmlns="" class="link" href="service.rest.html#service.rest-javascript.api" title="137.12 JavaScript Client API">JavaScript Client API</a>.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="service.rest-resource.identifiers"></a><span xmlns="" class="number">137.2.1</span> Resource Identifier Overview
</h3>
</div>
</div>
</div>
<p>The REST Management Service comprises of a set of resources that
can be retrieved and in some cases also modified through REST requests.
These resources need to be made available under well-defined paths so
that clients can interact with them. As the initial entry point a client
receives a URL to the REST Management Service. This can be done, e.g.,
as part of the creation of a cloud-based OSGi framework, and the precise
mechanism would be proprietary to the cloud platform used. Relative to
this URL the client can access the resources through the following
resource identifiers:
</p><pre xmlns="" class="programlisting"><code>framework
framework/state
framework/startlevel
framework/bundles
framework/bundles/representations
framework/bundle/{bundleid}
framework/bundle/{bundleid}/state
framework/bundle/{bundleid}/startlevel
framework/bundle/{bundleid}/header
framework/services
framework/services/representations
framework/service/{serviceid}</code></pre><p><code class="code">framework/bundle/0/state</code> is an alias for
<code class="code">framework/state</code></p>
<p>Extensions to the REST Management Service can be discovered by
visiting the Extensions Resource at:
</p><pre xmlns="" class="programlisting"><code>extensions</code></pre><p>For more details on the extension mechanism see <a xmlns="" class="xref" href="service.rest.html#service.rest-extensions" title="137.6 Extending the REST Management Service">Extending the REST Management Service</a></p>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="service.rest-resource.filters"></a><span xmlns="" class="number">137.2.2</span> Filtering Results
</h3>
</div>
</div>
</div>
<p>The <code class="code">bundles</code>, <code class="code">bundles/representations</code>,
<code class="code">services</code>, and <code class="code">services/representations</code>
resources allow the use of a query parameter which specifies a filter to
restrict the result set. The filter expression follows the Core
Specifications <span class="emphasis"><em>Framework Filter Syntax</em></span>; see <a xmlns="" class="xref" href="service.rest.html#service.rest-corefilter" title="Framework Filter Syntax">[1] <em>Framework Filter Syntax</em></a>.
</p>
<p>Filters on services are matched against the service attributes.
The query parameter is of the form:
</p>
<p><code class="code">framework/services?filter=ldap-filter</code></p>
<p>Filters on bundles are matched against the attributes of
capabilities in the respective namespaces. Filters on bundles have the
form:
</p>
<p><code class="code">framework/bundles?namespace1=ldap-filter1&namespace2=ldap-filter2&...</code></p>
<p>If multiple capabilities for a given namespace are present, then a
filter succeeds when one of these capabilities matches. When multiple
filter expressions across namespaces are given, these are combined with
the <span class="emphasis"><em>and</em></span> operator.
</p>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80631"></a><span xmlns="" class="number">137.2.3</span> Content Type Matching
</h3>
</div>
</div>
</div>
<p>Resources can present themselves through different representation
variants. An implementation of this specification must support at least
the JSON representation and the XML representation of resources. Clients
can support a subset of representations. Matching the clients
capabilities to understand certain representation formats with the
servers supported formats follows the typical HTTP pattern of content
negotiation and requires the client to set corresponding HTTP Accept
headers for supported formats in the form of their media types. This
specification describes the format and media types for representations
in JSON and XML format in <a xmlns="" class="xref" href="service.rest.html#service.rest-representation" title="137.4 Representations">Representations</a>.
</p>
<p>Implementations of the REST Management Service offering different
variants of representations must return the best matching variant based
on the HTTP accept header. In addition, they must respect the file
extensions defined for the different media types as specified in the
respective IETF RFC (e.g., ".xml" as specified in IETF RFC 3032 and
".json" as specified in IETF RFC 4627). If a file extension is appended
to the resource, an implementation must return the variant mandated by
the file extension provided that it supports this content type.
</p>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h2 xmlns="http://www.w3.org/1999/xhtml" class="title" style="clear: both"><a xmlns="" class="anchor" id="d0e80640"></a><span xmlns="" class="number">137.3</span> Resources
</h2>
</div>
</div>
</div>
<p>The framework and its state is mapped to a set of different
resources. Each resource is accessible through a resource identifier, as
summarized in <a xmlns="" class="xref" href="service.rest.html#service.rest-resource.identifiers" title="137.2.1 Resource Identifier Overview">Resource Identifier Overview</a>.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80647"></a><span xmlns="" class="number">137.3.1</span> Framework Startlevel Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/startlevel</code></p>
<p>The startlevel resource represents the active start level of the
framework. It supports the GET and PUT requests.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80655"></a><span xmlns="" class="number">137.3.1.1</span> GET
</h4>
</div>
</div>
</div>
<p>The GET request retrieves a <a xmlns="" class="xref" href="service.rest.html#service.rest-framework.startlevel.representation" title="137.4.5 Framework Startlevel Representation">Framework Startlevel Representation</a> from the REST management service. The
request can return the following status codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a startlevel representation.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80669"></a><span xmlns="" class="number">137.3.1.2</span> PUT
</h4>
</div>
</div>
</div>
<p>The PUT request sets the target framework startlevel. The body
of the request needs to be a <a xmlns="" class="xref" href="service.rest.html#service.rest-framework.startlevel.representation" title="137.4.5 Framework Startlevel Representation">Framework Startlevel Representation</a>. The request can return the following status
codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>204 (NO CONTENT): the request was received and valid. The
framework will asynchronously start to adjust the framework
startlevel until the target startlevel has been reached.
</p>
</li>
<li class="listitem">
<p>415 (UNSUPPORTED MEDIA TYPE): the request had a media type
that is not supported by the REST management service.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received an
IllegalArgumentException when trying to adjust the framework
startlevel, e.g., because the requested startlevel was zero or
negative.
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80686"></a><span xmlns="" class="number">137.3.2</span> Bundles Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/bundles</code></p>
<p>The bundles resource represents the list of all bundles installed
on the managed framework. It supports the GET request and two
syntactically different forms of POST requests which are used to install
new bundles to the framework.
</p>
<p>Results for this resource can be filtered as described in <a xmlns="" class="xref" href="service.rest.html#service.rest-resource.filters" title="137.2.2 Filtering Results">Filtering Results</a>.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80698"></a><span xmlns="" class="number">137.3.2.1</span> GET
</h4>
</div>
</div>
</div>
<p>The GET request retrieves a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.list.representation" title="137.4.2.1 Bundle List Representation">Bundle List Representation</a> from the REST management service. The
request can return the following status codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a bundle list representation.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="service.rest-bundles.post.location"></a><span xmlns="" class="number">137.3.2.2</span> POST with Location String
</h4>
</div>
</div>
</div>
<p>The POST request installs a new bundle to the managed framework
and thereby logically appends it to the bundles resource. The new
bundle to be installed is referenced by a location string which is
passed as the body of the request. In order to disambiguate the
request from the other form of POST, the content type must be set to
text/plain. In practice, the location string is usually a URL. Since
the framework will use the location retrieving the physical bundle, it
needs to be accessible from the remotely managed framework and not
necessarily from the managing client.
</p>
<p>The management service implementation must check if the result
of the install request matches the requested bundle since the OSGi
framework will return an existing bundle object as the return value of
an install call if there was already one with the same location string
installed. One way of doing it is comparing the last modification
timestamp. A detected collision is indicated to the requesting clients
through an error code 409.
</p>
<p>The body of the response is a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>
of the newly installed bundle. The following status codes can be
returned:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the bundle has been successfully installed and the
body of the response contains a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received a
BundleException when trying to install. The body of the message is
a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.exception.representation" title="137.4.9 Bundle Exception Representation">Bundle Exception Representation</a> describing the reason why the
installation did not succeed.
</p>
</li>
<li class="listitem">
<p>409 (CONFLICT): there is already a bundle installed with the
same location string.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="service.rest-bundles.post.bundle"></a><span xmlns="" class="number">137.3.2.3</span> POST with Bundle
</h4>
</div>
</div>
</div>
<p>This variant of the POST request uploads the bundle as the body
of the request. The media type of the request should be set to
application/vnd.osgi.bundle which must be supported by all REST
management services. Implementations are free to accept other media
types for this request with the exception of text/plain. For instance,
they can opt to additionally support application/zip or
application/x-jar.
</p>
<p>Clients should use the HTTP Content-Location field to set a
bundle location. If no content location is given, REST management
service implementations must generate a unique location string in
order to avoid unintended collisions between unrelated bundles.
</p>
<p>The body of the response is <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>
of the newly installed bundle. The following status codes can be
returned:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the bundle has been successfully installed and the
body of the response contains the URI.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received a
BundleException when trying to install. The body of the message is
a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.exception.representation" title="137.4.9 Bundle Exception Representation">Bundle Exception Representation</a> describing the reason why the
installation did not succeed.
</p>
</li>
<li class="listitem">
<p>409 (CONFLICT): there is already a bundle installed with the
same location string.
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80760"></a><span xmlns="" class="number">137.3.3</span> Bundles Representations Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/bundles/representations</code></p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80766"></a><span xmlns="" class="number">137.3.3.1</span> GET of the Representations
</h4>
</div>
</div>
</div>
<p>The <code class="code">bundles</code> resource returns a list of the URIs of
all bundles installed on the framework. For clients interested in the
details of multiple bundles there is also the possibility to retrieve
the bundle representation of each installed bundle with a single
request through the <span class="emphasis"><em>bundles/representations</em></span>
resource.
</p>
<p>The body of the response is a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representations.list.representation" title="137.4.2.2 Bundle Representations List Representation">Bundle Representations List Representation</a>. The request can return the following status
codes:
</p>
<p>Results for this resource can be filtered as described in <a xmlns="" class="xref" href="service.rest.html#service.rest-resource.filters" title="137.2.2 Filtering Results">Filtering Results</a>.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a bundle list representation.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80792"></a><span xmlns="" class="number">137.3.4</span> Bundle Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/bundle/{bundleid}</code></p>
<p>The bundle resource represents a single, distinct bundle in the
system. Hence, it has to be qualified by a bundle id. The resource
supports the GET, two variants of PUT, and the DELETE requests.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80800"></a><span xmlns="" class="number">137.3.4.1</span> GET
</h4>
</div>
</div>
</div>
<p>The GET request retrieves a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>
from the REST management service. The request can return the following
status codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a bundle representation.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80817"></a><span xmlns="" class="number">137.3.4.2</span> PUT with Location String
</h4>
</div>
</div>
</div>
<p>The PUT request updates the bundle with a new version,
referenced by a location string which is passed as the body of the
request. In order to disambiguate the request from the other form of
PUT, the content type must be set to text/plain. The same rationale
applies as for <a xmlns="" class="xref" href="service.rest.html#service.rest-bundles.post.location" title="137.3.2.2 POST with Location String">POST with Location String</a> and <a xmlns="" class="xref" href="service.rest.html#service.rest-bundles.post.bundle" title="137.3.2.3 POST with Bundle">POST with Bundle</a>, if a location string is
given it must point to a location reachable by the managed framework.
If no location string is passed as the body of the request, the
framework will perform an update based on the existing bundle's
location string.
</p>
<p>The body of the response is <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>
of the updated bundle. The following status codes can be
returned:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>204 (NO CONTENT): the request was received and valid and the
framework has issued the update.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received a
BundleException when trying to update. The body of the message is
a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.exception.representation" title="137.4.9 Bundle Exception Representation">Bundle Exception Representation</a> describing the reason why the update did
not succeed.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80842"></a><span xmlns="" class="number">137.3.4.3</span> PUT with Bundle
</h4>
</div>
</div>
</div>
<p>The PUT request updates the bundle with a new version, uploaded
as the body of the request. The media type of the request should be
set to application/vnd.osgi.bundle which must be supported by all REST
management services. Implementations are free to accept other media
types for this request with the exception of text/plain. For instance,
they can opt to additionally support application/zip or
application/x-jar.
</p>
<p>The body of the response is <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>
of the updated bundle. The following status codes can be
returned:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>204 (NO CONTENT): the request was received and valid and the
framework has issued the update.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received a
BundleException when trying to update. The body of the message is
a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.exception.representation" title="137.4.9 Bundle Exception Representation">Bundle Exception Representation</a> describing the reason why the update did
not succeed.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80863"></a><span xmlns="" class="number">137.3.4.4</span> DELETE
</h4>
</div>
</div>
</div>
<p>The DELETE request uninstalls the bundle from the
framework.
</p>
<p>The body of the response is <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.representation" title="137.4.1 Bundle Representation">Bundle Representation</a>
of the uninstalled bundle, where the bundle state will be UNINSTALLED.
The following status codes can be returned:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>204 (NO CONTENT): the request was received and valid and the
framework has uninstalled the bundle.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received a
BundleException when trying to uninstall. The body of the message
is a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.exception.representation" title="137.4.9 Bundle Exception Representation">Bundle Exception Representation</a> describing the reason why the
uninstallation did not succeed.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80884"></a><span xmlns="" class="number">137.3.5</span> Bundle State Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/bundle/{bundleid}/state</code></p>
<p>The bundle state resource represents the internal state of an
installed bundle qualified through its bundle id. It supports the GET
and PUT requests.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80892"></a><span xmlns="" class="number">137.3.5.1</span> GET
</h4>
</div>
</div>
</div>
<p>The GET request retrieves a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.state.representation" title="137.4.3 Bundle State Representation">Bundle State Representation</a> from the REST management service. The
request can return the following status codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a bundle state representation.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80909"></a><span xmlns="" class="number">137.3.5.2</span> PUT
</h4>
</div>
</div>
</div>
<p>The PUT request sets the target state for the given bundle. This
can, e.g., be state=32 for transitioning the bundle to started, or
state=4 for stopping the bundle and transitioning it to resolved. The
body of the request needs to be a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.state.representation" title="137.4.3 Bundle State Representation">Bundle State Representation</a>. Not all state transitions are valid. The
body of the response is the new <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.state.representation" title="137.4.3 Bundle State Representation">Bundle State Representation</a>. The request can return the following status
codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request was received and valid. The framework
has performed a state change and the new bundle state is contained
in the body.
</p>
</li>
<li class="listitem">
<p>400 (BAD REQUEST): the REST management service received a
BundleException when trying to perform the state transition. The
body of the message is a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.exception.representation" title="137.4.9 Bundle Exception Representation">Bundle Exception Representation</a> describing the reason why the operation
did not succeed.
</p>
</li>
<li class="listitem">
<p>402 (PRECONDITION FAILED): the requested target state is not
reachable from the current bundle state or is not a target state.
An example such state is the STOPPING state.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
<li class="listitem">
<p>415 (UNSUPPORTED MEDIA TYPE): the request had a media type
that is not supported by the REST management service.
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80936"></a><span xmlns="" class="number">137.3.6</span> Bundle Header Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/bundle/{bundleid}/header</code></p>
<p>The bundle header resource represents manifest header of a bundle
which is qualified by its bundle id. It can only be read through a GET
request.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80944"></a><span xmlns="" class="number">137.3.6.1</span> GET
</h4>
</div>
</div>
</div>
<p>The GET request retrieves a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.header.representation" title="137.4.4 Bundle Header Representation">Bundle Header Representation</a> from the REST management service. The raw
header value is used unless an <code class="code">Accept-Language</code> header is
set on the HTTP request. If multiple accepted languages are set only
the first is used to localize the header. The request can return the
following status codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a bundle header representation.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80964"></a><span xmlns="" class="number">137.3.7</span> Bundle Startlevel Resource
</h3>
</div>
</div>
</div>
<p><code class="code">framework/bundle/{bundleid}/startlevel</code></p>
<p>The bundle startlevel resource represents the start level of the
bundle qualified by its bundle id. It supports the GET and PUT
requests.
</p>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80972"></a><span xmlns="" class="number">137.3.7.1</span> GET
</h4>
</div>
</div>
</div>
<p>The GET request retrieves a <a xmlns="" class="xref" href="service.rest.html#service.rest-bundle.startlevel.representation" title="137.4.6 Bundle Startlevel Representation">Bundle Startlevel Representation</a> from the REST management service. The
request can return the following status codes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>200 (OK): the request has been served successfully and the
body of the response is a bundle startlevel representation.
</p>
</li>
<li class="listitem">
<p>404 (NOT FOUND): there is not bundle with the given bundle
id.
</p>
</li>
<li class="listitem">
<p>406 (NOT ACCEPTABLE): the REST management service does not
support any of the requested representations.
</p>
</li>
</ul>
</div>
</div>
<div class="section">
<div xmlns="" class="titlepage">
<div>
<div>
<h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="" class="anchor" id="d0e80989"></a><span xmlns="" class="number">137.3.7.2</span> PUT