Managing LOB-specific APIs for testing and integration

The Product Definition API provides endpoints that can be used to import, visualize, and generate code for products from Advanced Product Designer product templates. These APIs are designed to assist you in managing your product testing and integration. For building product models, Guidewire recommends using Advanced Product Designer directly.

Importing a product template through the API

The Product Definition API provides a set of endpoints that can be used to import a product from an Advanced Product Designer (APD) product template.

Endpoint Template type Input file format
/productdefinition/v1/import-template An APD product template XML
/productdefinition/v1/import-edition An APD product template, imported as a product edition XML
/productdefinition/v1/import-xmind An XMind mind map that can be used to generate an APD product template XMIND
/productdefinition/v1/import-json An APD product template JSON

In the request body, Content-Type must be set to multipart/form-data, and the product template file must be passed through the content parameter.

The following example shows a partial request header for a call that imports a BPP-PetBusinessOwners-template.xml file:

 > POST /pc/rest/productdefinition/v1/import-template HTTP/1.1
 > Accept-Encoding: gzip,deflate
 > Authorization: Basic c3U6Z3c=
 > Connection: Keep-Alive
 > Content-Type: multipart/form-data; boundary=--------iSl9mNZkwq31beJX5v
 > Transfer-Encoding: chunked

 > --------iSl9mNZkwq31beJX5v
 > Content-Type: text/xml
 > Content-Disposition: form-data; content="BPP-PetBusinessOwners-template.xml"

    (content of BPP-PetBusinessOwners-template.xml)
  > --------iSl9mNZkwq31beJX5v--

A successful request returns the following response body:

{
    "data": {
        "attributes": {
            "id": "Petbusinessowners"
        }
    }
}

By default, the imported product template is loaded in PolicyCenter as a visualized product, and its LOB-specific APIs are enabled for inspection.

Product editions

A product edition defines product model properties and subclause relationships for a product line. Product editions can be used to introduce changes to the product after a product has gone into production. A product edition is packaged as an APD template, and can be imported as described above, provided the base product is already installed.

To activate the product edition, a caller can submit a POST request to the /productdefinition/v1/lines/{lineId}/activate-editions endpoint. The request body must contain a lineId property containing the product edition identifier:

{
  "data": {
    "attributes": {
      "lineId": "Petbusinessowners-2"
    }
  }
}

Querying for product templates

Authorized internal users can query for product templates. Authorized callers can use the following endpoints to retrieve product template resources:

  • /productdefinition/v1/product-templates
  • /productdefinition/v1/product-templates/{productId}

For example, a ProductTemplate resource for a Pet Business Owners product appears as follows:

{
    "data": {
        "attributes": {
            "abbreviation": "PBP",
            "codeIdentifier": "PetBusinessOwners",
            "description": "Pet Business Owners",
            "enabled": true,
            "id": "Petbusinessowners",
            "name": "Petbusinessowners",
            "productAccountType": {
                "code": "Any",
                "name": "Any"
            }
        },
        . . .
        "links": {
            "codegen": {
                "href": "/productdefinition/v1/product-templates/Petbusinessowners/codegen",
                "methods": [
                    "post"
                ]
            },
            "disable": {
                "href": "/productdefinition/v1/product-templates/Petbusinessowners/disable",
                "methods": [
                    "post"
                ]
            },
            "self": {
                "href": "/productdefinition/v1/product-templates/Petbusinessowners",
                "methods": [
                    "delete",
                    "get"
                ]
            }
        }
    }
}

Toggling the active state of a visualized product

By default, importing a product template creates a product in visualized mode and enables its API for queries. The Product Definition API provides endpoints for toggling this state:

  • /productdefinition/v1/product-templates/{productId}/enable
  • /productdefinition/v1/product-templates/{productId}/disable

The request body for either call is the same. It contains a productId property whose value is the product identifier.

{
    "data": {
        "attributes": {
            "productId": "Petbusinessowners"
        }
    }
}

The response body contains the associated ProductTemplate resource. The enabled property displays a Boolean value indicating whether the product is enabled or disabled.

{
    "data": {
        "attributes": {
            "abbreviation": "PBP",
            "codeIdentifier": "PetBusinessOwners",
            "description": "Pet Business Owners",
            "enabled": false,
            "id": "Petbusinessowners",
            "name": "Petbusinessowners",
            . . .
        },
        . . .
    }
}

Generating code from a visualized product

In PolicyCenter, authorized users can generate several types of code from a visualized product.

Code type Description Installed location in PolicyCenter
Base product code All code necessary to enable complete product functionality in PolicyCenter

/pc/app-pc/pc-apd-genlob-content/config/extensions/

/pc/app-pc/pc-apd-genlob-content/config/locale/

/pc/app-pc/pc-apd-genlob-content/config/lookuptables/

/pc/app-pc/pc-apd-genlob-content/config/resources/

/pc/app-pc/pc-apd-genlob-content/config/web/

/pc/app-pc/pc-apd-genlob-content/displaynames/

/pc/app-pc/pc-apd-genlob-content/gsrc/

API code API-related code (Swagger, schema, mapper, updater, and resource files) /pc/app-pc/pc-lob-{lobId}
API test code API test stubs, using the Karate testing framework (these tests belong to the customer to maintain and are not considered product) /pc/apitestbench/customer-api/src/test/java/gw/pc/customer/api/lob/{lobId}
External A function stub that can be used to hook in code extensions /pc/app-pc/pc-apd-genlob-content/config/extensions/

({lobId} refers to the three-character abbreviation used in LOB names, such as "BOP")

To generate code from a visualized product, authorized callers can submit a POST request to the /productdefinition/v1/product-templates/{productId}/codegen endpoint.

The request body can include the generationMode property, set to one of the following values:

  • ALL: Generate API and product base code
  • API_CODE: Generate code for the API only
  • BASE_CODE: Generate product base code only
  • EXTERNAL: Generate extensions code only

By default, this value is set to ALL.

The following code block displays a request body for generating the API code for a Pet Business Owners product:

{
    "data": {
        "attributes": {
            "productId": "Petbusinessowners"
            "generationMode": "API_CODE"
        }
    }
}

Deleting a product template

To delete a product template, authorized callers can submit a business action POST to the /productdefinition/v1/product-templates/{productId}/delete endpoint.