[GIS] How to request an sld style from geoserver by name

sld

I know that I can get the styles for a layer with a getstyles request, for example:

http://geoserver.myserver.com/geoserver/wms?request=GetStyles&layers=agdd_50f&service=wms&version=1.1.1

returns the following two styles associated with the layer:

<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
    <sld:NamedLayer>
        <sld:Name>agdd_50f</sld:Name>
        <sld:UserStyle>
            <sld:Name>agdd</sld:Name>
            <sld:Title>AGDD</sld:Title>
            <sld:IsDefault>1</sld:IsDefault>
            <sld:FeatureTypeStyle>
                <sld:Name>name</sld:Name>
                <sld:Rule>
                    <sld:RasterSymbolizer>
                        <sld:ColorMap>
                            <sld:ColorMapEntry color="#FFFFFF" quantity="0" label=""/>
                            <sld:ColorMapEntry color="#deebf7" quantity="10" label="10"/>
                            <sld:ColorMapEntry color="#FBD694" quantity="8000" label="8000"/>
                            <sld:ColorMapEntry color="#F9C37D" quantity="9000" label="9000"/>
                            <sld:ColorMapEntry color="#F8B167" quantity="10000" label="10000"/>
                            <sld:ColorMapEntry color="#F69E50" quantity="11000" label="11000"/>
                            <sld:ColorMapEntry color="#F48C39" quantity="12000" label="12000"/>
                            <sld:ColorMapEntry color="#F37A23" quantity="13000" label="13000"/>
                        </sld:ColorMap>
                        <sld:ContrastEnhancement/>
                    </sld:RasterSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>
        </sld:UserStyle>
        <sld:UserStyle>
            <sld:Name>emerald_ash_borer</sld:Name>
            <sld:Title>Emerald Ash Borer</sld:Title>
            <sld:FeatureTypeStyle>
                <sld:Name>name</sld:Name>
                <sld:Rule>
                    <sld:RasterSymbolizer>
                        <sld:ColorMap>
                            <sld:ColorMapEntry color="#FFFFFF" quantity="0" label="0 No Accumulation"/>
                            <sld:ColorMapEntry color="#3288bd" quantity="350" label="350 Not Approaching treatment window"/>
                            <sld:ColorMapEntry color="#99d594" quantity="450" label="450 Approaching treatment window"/>
                            <sld:ColorMapEntry color="#e6f598" quantity="550" label="550 First treatment window (right on emergence)"/>
                            <sld:ColorMapEntry color="#fee08b" quantity="1500" label="1500 Second treatment window (second spray)"/>
                            <sld:ColorMapEntry color="#d53e4f" quantity="1501" label="&gt;1500 Treatment window passed"/>
                        </sld:ColorMap>
                        <sld:ContrastEnhancement/>
                    </sld:RasterSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>
        </sld:UserStyle>
    </sld:NamedLayer>
</sld:StyledLayerDescriptor>

However I only want the emerald_ash_borer style by itself. How can I request just this sld?

I've also tried something like: geoserver.myserver.org/geoserver/workspaces/gdd/styles/emeral_ash_borer.sld
from this documentation, but doesn't seem to be a valid request.

The reason I'm trying to do this is to pass the style to a wps request:

<wps:Input>
    <ows:Identifier>style</ows:Identifier>
    <wps:Reference mimeType="text/xml; subtype=sld/1.1.1" xlink:href="http://mygeoserver/geoserver/wms?request=GetStyles&amp;layers=${layerName}&amp;service=wms&amp;version=1.1.1" method="GET"/>
</wps:Input>

Best Answer

You can use the REST API to fetch styles by using a link like:

http://localhost:8080/geoserver/rest/styles/green.sld
Related Question