J

Thursday, October 21st, 2021 8:00 PM

change asset request spring boot

Hi Team, I have a customer who is utilizing spring boot and trying to run the changeassetrequest and they noticed that the setid is not an option for them to use. This is a valid parameter. did the customer miss something or is this not included?

4 Messages

3 years ago

Hi Jasmine,

The ID of an asset is immutable. It cannot be changed via the REST Core API PATCH assets endpoint, nor via the Collibra CLI generated ChangeAssetRequest class (which is exactly the same class contained in the Spring Boot integration library)

2 Messages

3 years ago

Hi James,

The customer understands that its immutable. However they are inquiring the following:

I agree that the ID of an asset is immutable. But what I’m trying to do is to update/change the properties of an asset such as status, name etc. using the resource Id in Spring Boot library. But unfortunately there is no method/function to update/change the asset using the ID in the Spring Boot library.

4 Messages

Hi Jasmine,

OK, now I understand your request.

Actually, it is possible to identify an asset you want to update/change via its Resource ID. This is done as follows:

  1. @Autowired
    private ApiClient apiClient;

  2. AssetsApi assetApi = apiClient.buildClient(AssetsApi.class);

  3. ChangeAssetRequest changeAssetRequest = new ChangeAssetRequest()
    .name(“New Full Name”)
    .displayName(“New Display Name”)
    .statusId(UUID.fromString(“00000000-0000-0000-0000-000000005057”));

  4. AssetImpl updatedAsset = assetApi.changeAsset(UUID. fromString (“9358e86e-9718-4610-bbbd-e43505aba9cb”), changeAssetRequest);

This is an explanation of each step:

  1. You need to autowire an ApiClient bean as a class field, to be able to use any of the generated Core API classes.

  2. Initialize an AssetApi object, to be able to use the Core API PATCH /assets/{assetId} operation.

  3. Construct a ChangeAssetRequest object (using builder methods), to set the details you want to change/update. In the example above, I’m changing the asset full name, display name and status.

  4. Use the AssetApi’s changeAsset method (which internally is calling the Core API PATH /assets/{assetId} operation) to perform the change/update. This method takes the asset resource id as its first argument (which answers your question) and the ChangeAssetRequest object as its second argument. This method returns an AssetImpl object containing the details of the updated/changed asset.

Loading...