If I remember the code both POST and PUT are supported. Patch grabs the
existing catalog item, applies the change to it, and saves...

https://github.com/geoserver/geoserver/blob/master/src/restconfig/src/main/java/org/geoserver/catalog/rest/FeatureTypeResource.java#L87



--
Jody Garnett

On 6 July 2016 at 17:16, James Sewell <[email protected]> wrote:

> Hello All,
>
> I've been using the REST API  lately, which has been a bit problematic for
> me.
>
> Is there a way to change a single parameter for an object from a single
> REST call? For example, change the database name for a data store?
>
> I suppose what I'm after is PATCH rather than PUT, as PUT is supposed to
> be atomic.
>
> At the moment it looks like you would have to:
>
>    1. Do a GET to get the current config
>    2. Load the response to a data structure
>    3. Merge the response with your desired change (this would be a lot
>    easier if the JSON was standard key:value)
>    4. Do a PUT to make the merged change active
>
> As I said I can see why PUT shouldn't do this, but to show what I mean
> here is an example of it not working from a PUT:
>
> Say I've got a datastore:
>
> # curl -u admin:geoserver -GET
> http://192.168.2.237:8080/geoserver/rest/workspaces/tester/datastores/Test.xml
> <dataStore>
>   <name>Test</name>
>   <type>PostGIS</type>
>   <enabled>true</enabled>
>   <workspace>
>     <name>tester</name>
>     <atom:link xmlns:atom="http://www.w3.org/2005/Atom"; rel="alternate"
> href="http://192.168.2.237:8080/geoserver/rest/workspaces/tester.xml";
> type="application/xml"/>
>   </workspace>
>   <connectionParameters>
>     <entry key="schema">public</entry>
>     <entry key="database">postgres</entry>
>     <entry key="passwd">crypt1:mWGfLiNZL8UOZCpLkRE7mw==</entry>
>     <entry key="host">localhost</entry>
>     <entry key="namespace">http://james</entry>
>     <entry key="user">postgres</entry>
>   </connectionParameters>
>   <__default>true</__default>
>   <featureTypes>
>     <atom:link xmlns:atom="http://www.w3.org/2005/Atom"; rel="alternate"
> href="
> http://192.168.2.237:8080/geoserver/rest/workspaces/tester/datastores/Test/featuretypes.xml";
> type="application/xml"/>
>   </featureTypes>
> </dataStore>
>
>
> Then I want to change the database name from 'postgres' to
> 'postgres-test', so I sent the following XML in a PUT request:
>
> <dataStore>
>   <name>Test</name>
>   <type>PostGIS</type>
>   <connectionParameters>
>     <database>postgres-test</database>
>    /connectionParameters>
> </dataStore>
>
> But this removes the other config:
>
> # curl -u admin:geoserver -GET
> http://192.168.2.237:8080/geoserver/rest/workspaces/tester/datastores/Test.xml
> <dataStore>
>   <name>Test</name>
>   <type>PostGIS</type>
>   <enabled>true</enabled>
>   <workspace>
>     <name>tester</name>
>     <atom:link xmlns:atom="http://www.w3.org/2005/Atom"; rel="alternate"
> href="http://192.168.2.237:8080/geoserver/rest/workspaces/tester.xml";
> type="application/xml"/>
>   </workspace>
>   <connectionParameters>
>     <entry key="database">postgres-test</entry>
>   </connectionParameters>
>   <__default>true</__default>
>   <featureTypes>
>     <atom:link xmlns:atom="http://www.w3.org/2005/Atom"; rel="alternate"
> href="
> http://192.168.2.237:8080/geoserver/rest/workspaces/tester/datastores/Test/featuretypes.xml";
> type="application/xml"/>
>   </featureTypes>
> </dataStore>
>
>
>
> James Sewell,
> PostgreSQL Team Lead / Solutions Architect
> ______________________________________
>
>
> Level 2, 50 Queen St, Melbourne VIC 3000
>
> *P *(+61) 3 8370 8000  *W* www.lisasoft.com  *F *(+61) 3 8370 8099
>
>
> ------------------------------
> The contents of this email are confidential and may be subject to legal or
> professional privilege and copyright. No representation is made that this
> email is free of viruses or other defects. If you have received this
> communication in error, you may not copy or distribute any part of it or
> otherwise disclose its contents to anyone. Please advise the sender of your
> incorrect receipt of this correspondence.
>
>
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> Geoserver-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
>
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to