given a JSON path that points to a string value, this plugin will scan the the associated API Resources of the API Namespace it is run against to output a unique list of API Resources to a target API Namespace

Namespace

NA since it runs on an existing Namespace

Properties

resolve_string_path: "api_namespace_slug.some_property.another_property" output_api_namespace: "api_namespace_slug" pristine: boolean

Algorithm

Validations

  1. resolve_string_path's api_namespace_slug should be the same API Namespace the External API Connection is running on.
  2. raise exception "API Namespace resource pollution detected, check resolve_string_path and output_api_namespace" if resolve_string_path's "api_namespace_slug" and output_api_namespace's "api_namespace_slug" are the same
  3. if pristine is set to true, collect all ID's of all existing API Resources in the target API Namespace and delete them after successful connection execution

Logic

  1. if pristine is set to true: calculate all the ID's of the API resources to delete in the target API Namespace, assign that to a variable

  2. Access the resolve_string_path in the current API Namespace, and loop over all the API Resources building a hash map of it.

  3. Take the hash map and loop over the keys creating an API Resource in the target namespace for each key. The created API Resources should have the following format:
    property_name (derived form "api_namespace_slug.some_property.another_property" inresolve_string_path )

{
`property_name`: "string value"  
}

Example

API Namespace: Movies

title: 'titanic',
tags: ['romance', 'shipbuilding']

given an API Namespace of movies, build a unique list of tags that each movie is tagged under.

0

@Sushmit1997 have you had a chance to take a look at this?

0

@donrestarone Yes, I'm looking at this. Will post estimates shortly.

0

@Sushmit1997 have you had a chance to take a look at this?

I've posted estimate for this task in my backlog.

0

@donrestarone

In logic number 1, what does assign that to a variable means? And I didn't get logic number 3

CC @Pralish @alis-khadka

0

@Sushmit1997

  1. This is to ensure that the unique index is rebuilt each time the plugin is run. You should capture the existing ID's (if any) into a variable and destroy them after the algorithm runs (this is the stale set)

Example:

API Namespace: Movies attributes: title, tags (array)

title: Titanic tags: ['romance', ships]

title: Hunt for Red October tags: ['cold war', 'ships']

title: Lost tags: ['fantasy']

  • the very first time the plugin runs over the above data set, there will be nothing to destroy (because there are no tags in the target namespace
  • the second time the plugin runs over the above data set, it should first calculate all the existing tags (eg: romance, ships, Cold War, fantasy)-- run the algorithm and delete the old ones before inserting the new ones (eg: romance, ships, Cold War, fantasy)
1

@donrestarone What exactly do you mean by hash map?

Is it the array of something like

title: Hunt for Red October tags: ['cold war', 'ships']

and can you give an example of logic 3? It would be easier to understand with clear example.

0

@Sushmit1997 its a hash (see corrected). It maps as follows:

{
'cold war' => [API_RESOURCE_IDS],
'fantasy' => [API_RESOURCE_IDS],
}

The API_RESOURCE_IDS above are the API_RESOURCE_IDS of the movies Titanic, Lost etc

0

@Ayon95 any updates on this?

0

Is it necessary to build a hash? Our aim is to look at all the array values of one property of each API resource and then generate an array of unique values.

0
© 2022 pullanswer.com - All rights reserved.