-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
recreate endpoints for signage, sitenow, etc to consume #7550
Comments
Grooming conversation... After some conversation, we decided we want to do a probe to see if we can understand who is using these endpoints. Is it just us or are others. Is it just the json endpoint or is there usage on the xml endpoint as well. Check splunk logs to see where referring traffic is coming from to understand. Shouldn't need to look back very far. Size the probe as a medium. |
active.xml active.json |
Grooming conversation... haven't found usage of the XML endpoint so we think we can retire that with communication. Seems like we are in favor of creating a new endpoint to replace the current JSON endpoint and update Signage/SiteNow and help others update to the new endpoint. We'll need to communicate this out. Once we have the new endpoint we can have this live in a non-production environment for folks to test with. Could communicate when a test alert is happening. Communicate launch date for folks to switch to the new endpoint. We may need to use stage for the v3 site for endpoint testing and revert back to having dev available for the D7 site. Need to include the more_info_link in the endpoint. That link should be set to emergency.uiowa.edu. This is not a field that needs to be edited or changed per alert node. This is more of a site wide setting. Possibly a pseudo field? Take a look at OnIowa events work for previous JSON API related work. We will need to test caching with this to make sure endpoint is getting updated as content gets created/edited. Scoped this to getting the endpoint setup with correct data and having it reviewed/tested. Additional slices can be created to get it available in stage and to handle communication. |
Did a short dive into create a custom resource as there is only one resource per entity bundle by default. It worked filtering on Looks like there will already be some unrelated custom work to account for I was following this article which got me up and running within a few minutes. routing.yml
<?php
namespace Drupal\emergency_core\Resource;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\jsonapi\ResourceResponse;
use Drupal\jsonapi_resources\Resource\EntityQueryResourceBase;
use Drupal\node\NodeInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Processes a request for a collection containing active hawk_alert nodes.
*/
class ActiveHawkAlerts extends EntityQueryResourceBase {
/**
* Process the resource request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*
* @return \Drupal\jsonapi\ResourceResponse
* The response.
*/
public function process(Request $request): ResourceResponse {
$cacheability = new CacheableMetadata();
/** @var \Drupal\Core\Entity\ContentEntityType $entity_type */
$entity_type = $this->entityTypeManager->getDefinition('node');
/** @var string $bundle_field */
$bundle_field = $entity_type->getKey('bundle');
/** @var string $status_field */
$status_field = $entity_type->getKey('status');
$entity_query = $this->getEntityQuery('node')
->condition($bundle_field, 'hawk_alert')
->condition('field_hawk_alert_complete', 0)
->condition($status_field, NodeInterface::PUBLISHED);
$cacheability->addCacheContexts(['url']);
$paginator = $this->getPaginatorForRequest($request);
$paginator->applyToQuery($entity_query, $cacheability);
$data = $this->loadResourceObjectDataFromEntityQuery($entity_query, $cacheability);
$pagination_links = $paginator->getPaginationLinks($entity_query, $cacheability, TRUE);
/** @var \Drupal\jsonapi\CacheableResourceResponse $response */
$response = $this->createJsonapiResponse($data, $request, 200, [], $pagination_links);
$response->addCacheableDependency($cacheability);
return $response;
}
} |
With JSON API Defaults as a submodule of JSON API Extras I was able to simplify the URL structure compared to #6580. I know the app-devs have hardcoded that long URL string for their app, but we could support a simpler URL if we were to revisit. |
Emergency website active hawk alerts endpoint changes
The other changes are in order to follow the JSON 1.0 specification:
|
Story
As an Emergency site owner, I would like Hawk Alert information to get consumed by Signage and SiteNow websites so folks can quickly and easily be made aware of emergencies without having to go to emergency.uiowa.edu.
Additional Info
Currently seeing feeds at the following endpoints:
Looks like signage is using https://emergency.uiowa.edu/api/active.json
Looks like the D7 uiowa_alerts module uses https://emergency.uiowa.edu/api/active.json
Looks like D10 uiowa_alerts module is using https://emergency.uiowa.edu/api/active.json
Is anything using https://emergency.uiowa.edu/api/active.xml? - Not that we found
We should adjust the
more_info_link
in the endpoint to be emergency.uiowa.edu rather than e.uiowa.eduProposed Solution
Tasks
The text was updated successfully, but these errors were encountered: