def _resolve_and_save_subscription(self, entity_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id): actual_id, unsaved_id = self._resolve(EntityType.subscription, entity_id, entity_map, actual_entities_by_unsaved_id) if actual_id: return actual_id node_id = self._node_id(EntityType.subscription, unsaved_id) subscription = Subscription.from_dict(entity_map['unsaved_entities'][node_id]) assert isinstance(subscription, Subscription) subscription.data.dataset_id = self._resolve_and_save_dataset(subscription.data.dataset_id, entity_map, actual_entities_by_node_id, actual_entities_by_unsaved_id) subscription = self._subscription_service.save_subscription(subscription, commit_and_generate=False, flush=True) actual_entities_by_node_id[node_id] = subscription actual_entities_by_unsaved_id[unsaved_id] = subscription return subscription.id
def post_subscription(dataset): subscription = Subscription.from_dict(request.get_json()) subscription.data.dataset_id = dataset.id subscription = subscription_service().save_subscription(subscription) return {'results': subscription.to_dict()}
def patch_subscription(subscription): """ :type subscription: dart.model.subscription.Subscription """ p = JsonPatch(request.get_json()) return update_subscription( subscription, Subscription.from_dict(p.apply(subscription.to_dict())))
def put_subscription(subscription): """ :type subscription: dart.model.subscription.Subscription """ return update_subscription(subscription, Subscription.from_dict(request.get_json()))
def put_subscription(subscription): s = Subscription.from_dict(request.get_json()) state = SubscriptionState.INACTIVE if s.data.state == SubscriptionState.INACTIVE else subscription.data.state subscription = subscription_service().update_subscription_name(subscription, s.data.name) subscription = subscription_service().update_subscription_state(subscription, state) return {'results': subscription.to_dict()}
def patch_subscription(subscription): """ :type subscription: dart.model.subscription.Subscription """ p = JsonPatch(request.get_json()) return update_subscription(subscription, Subscription.from_dict(p.apply(subscription.to_dict())))