Mailing List Archive

Services API for ChannelServices / Channel
Hi,

I've added column service_type to database table channel as part of
the implementation of ticket #8774.

I have now added the support for the Services API along the same lines
as previously done for the bouquet_id and the region_id. It is
convenient to assume that the version bump done by Bill yesterday does
also cover this change.

I've also made some changes to the python/perl/php bindings along the
lines of how it is done for the default_authority field. Hope that
nothing is broken but if it is then please let me know.

Groetjes,
Klaas.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Sat, Nov 2, 2019 at 4:23 PM Klaas de Waal <klaas.de.waal@gmail.com> wrote:

> I have now added the support for the Services API along the same lines
> as previously done for the bouquet_id and the region_id. It is
> convenient to assume that the version bump done by Bill yesterday does
> also cover this change.

That change is necessary, as It provides the
appropriate ability for a user (app) of the service
API to identify when enable the new features.

But that does not provide API backward
compatibility when using an existing endpoint
where existing codes which do not provide the
values do not get existing values overridden by
updates that do not provide them (likely using
something like the checks that were mentioned
by Roger to check if the names were supplied
in the post, and if not, do not update those
values in a row, or ensuring that existing values
are maintained (depending on how you wish
to write the code).

If you are in progress with these changes I
will just wait, but otherwise I can create a
number of release blocker tickets so that
v31 is not released prematurely. How do
you wish to proceed?
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Sun, 24 Nov 2019 at 16:38, Gary Buhrmaster <gary.buhrmaster@gmail.com> wrote:
>
> On Sat, Nov 2, 2019 at 4:23 PM Klaas de Waal <klaas.de.waal@gmail.com> wrote:
>
> > I have now added the support for the Services API along the same lines
> > as previously done for the bouquet_id and the region_id. It is
> > convenient to assume that the version bump done by Bill yesterday does
> > also cover this change.
>
> That change is necessary, as It provides the
> appropriate ability for a user (app) of the service
> API to identify when enable the new features.
>
> But that does not provide API backward
> compatibility when using an existing endpoint
> where existing codes which do not provide the
> values do not get existing values overridden by
> updates that do not provide them (likely using
> something like the checks that were mentioned
> by Roger to check if the names were supplied
> in the post, and if not, do not update those
> values in a row, or ensuring that existing values
> are maintained (depending on how you wish
> to write the code).
>
> If you are in progress with these changes I
> will just wait, but otherwise I can create a
> number of release blocker tickets so that
> v31 is not released prematurely. How do
> you wish to proceed?
>
To be honest, I was not aware that there needs to be done more than
what I have done already so there is nothing in progress.
So yes, please do create tickets and please be explicit and clear
about what is needed and why it is needed.

Groetjes,
Klaas.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On 11/24/19 3:12 PM, Klaas de Waal wrote:
> On Sun, 24 Nov 2019 at 16:38, Gary Buhrmaster <gary.buhrmaster@gmail.com> wrote:
>>
>> On Sat, Nov 2, 2019 at 4:23 PM Klaas de Waal <klaas.de.waal@gmail.com> wrote:
>>
>>> I have now added the support for the Services API along the same lines
>>> as previously done for the bouquet_id and the region_id. It is
>>> convenient to assume that the version bump done by Bill yesterday does
>>> also cover this change.
>>
>> That change is necessary, as It provides the
>> appropriate ability for a user (app) of the service
>> API to identify when enable the new features.
>>
>> But that does not provide API backward
>> compatibility when using an existing endpoint
>> where existing codes which do not provide the
>> values do not get existing values overridden by
>> updates that do not provide them (likely using
>> something like the checks that were mentioned
>> by Roger to check if the names were supplied
>> in the post, and if not, do not update those
>> values in a row, or ensuring that existing values
>> are maintained (depending on how you wish
>> to write the code).
>>
>> If you are in progress with these changes I
>> will just wait, but otherwise I can create a
>> number of release blocker tickets so that
>> v31 is not released prematurely. How do
>> you wish to proceed?
>>
> To be honest, I was not aware that there needs to be done more than
> what I have done already so there is nothing in progress.
> So yes, please do create tickets and please be explicit and clear
> about what is needed and why it is needed.

I *think* the attached is what Gary/Roger are suggesting. But when I
'signed on', a senior developer said there shouldn't be any SQL in the
API code (but there was already.)

At least it's something to talk about. [And way more than what's
needed for Klaas's changes]

It compiles, but I haven't tested it.

--
Bill
Re: Services API for ChannelServices / Channel [ In reply to ]
On Mon, Nov 25, 2019 at 6:22 AM Bill Meek <keemllib@gmail.com> wrote:

> I *think* the attached is what Gary/Roger are suggesting. But when I
> 'signed on', a senior developer said there shouldn't be any SQL in the
> API code (but there was already.)

(parenthetical comment: even senior devs can find
that they have to make compromises in the real
world unless they are one of the few with infinite
time to refactor all the codes).

That is one approach, another is to test for whether
the value was provided (as Roger demonstrated in
his reference), and, if not, do not update the columns
(using conditional creation of the update SQL to not
update columns not provided). Pseudo code follows.

And so can creating an entirely new endpoint,
although in this case I think that is overkill.

Any of those can work, so it would depend on what
makes sense as example going forward for other
new devs who are not otherwise familiar with their
requirements to maintain API compatibility (i.e.
the added code, whatever it will be, will typically
be copied for the next case).

As this is a question for the devs (they will have
to live with the solution going forward), I will defer
to them to decide which is the best way to propose
to fix the API breakage.

pseudo code:
// existing code (before new columns)
QString updateSQL
MSqlBindings bindings;

updateSQL = "Update table .... set column1 = :Column1, column2 = :Column2"
bindings[":Column1"] = Value1
bindings[":Column2"] = Value2

// Added code
if (m_parsedParams.contains("RegionId"))
updateSQL += " set regionid = :RegionId ";
bindings[":RegionId"] = RegionId;
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On 11/25/19 7:43 PM, Gary Buhrmaster wrote:
> On Mon, Nov 25, 2019 at 6:22 AM Bill Meek <keemllib@gmail.com> wrote:
>
>> I *think* the attached is what Gary/Roger are suggesting. But when I
>> 'signed on', a senior developer said there shouldn't be any SQL in the
>> API code (but there was already.)
>
> (parenthetical comment: even senior devs can find
> that they have to make compromises in the real
> world unless they are one of the few with infinite
> time to refactor all the codes).
>
> That is one approach, another is to test for whether
> the value was provided (as Roger demonstrated in
> his reference), and, if not, do not update the columns
> (using conditional creation of the update SQL to not
> update columns not provided). Pseudo code follows.
>
> And so can creating an entirely new endpoint,
> although in this case I think that is overkill.
>
> Any of those can work, so it would depend on what
> makes sense as example going forward for other
> new devs who are not otherwise familiar with their
> requirements to maintain API compatibility (i.e.
> the added code, whatever it will be, will typically
> be copied for the next case).
>
> As this is a question for the devs (they will have
> to live with the solution going forward), I will defer
> to them to decide which is the best way to propose
> to fix the API breakage.
>
> pseudo code:
> // existing code (before new columns)
> QString updateSQL
> MSqlBindings bindings;
>
> updateSQL = "Update table .... set column1 = :Column1, column2 = :Column2"
> bindings[":Column1"] = Value1
> bindings[":Column2"] = Value2
>
> // Added code
> if (m_parsedParams.contains("RegionId"))
> updateSQL += " set regionid = :RegionId ";
> bindings[":RegionId"] = RegionId;

Right, I'm using the m_parsedParms... solution. And in line SQL to get the existing values
and the existing call to SourceUtil::UpdateSource(). Testing now.

Fun fact: this endpoint broke mythfilldatabase if a user had a grabber
because the configpath gets set to "" rather than NULL. mythfilldatabase
depends on the NULL case to develop the path to the file automatically.
If ConfigPath=someValidPath, then it's OK.

--
Bill
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Tue, Nov 26, 2019 at 2:01 AM Bill Meek <keemllib@gmail.com> wrote:

> Fun fact: this endpoint broke mythfilldatabase if a user had a grabber
> because the configpath gets set to "" rather than NULL. mythfilldatabase
> depends on the NULL case to develop the path to the file automatically.
> If ConfigPath=someValidPath, then it's OK.

As I mentioned previously, there is a number
of cases where NULL does not equal empty
throughout the code base (sometimes for
good reasons, some times I am not so sure),
and the Services API generally does not
provide a way to set a NULL and/or an
empty value. Realistically there are only a
few apps today that try to implement an
alternative to mythtv-setup, so the impact is
limited, but as I understand it the stated goal
was to move towards a web based setup
(using the services API), which makes the
side cases more interesting to address.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Tue, Nov 26, 2019 at 2:01 AM Bill Meek <keemllib@gmail.com> wrote:

> Right, I'm using the m_parsedParms... solution. And in line SQL to get the existing values
> and the existing call to SourceUtil::UpdateSource().

Yes, I saw that, which is why I offered the
alternative pseudo code which does not
need to get the existing values at all,
because it will not update those columns
(there are various examples of this type
of constructed sql in other parts of the
code base). But I did not go so far as
to actually code anything, and working
code is better than just a concept.

Thanks.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On 11/24/19 9:37 AM, Gary Buhrmaster wrote:
> On Sat, Nov 2, 2019 at 4:23 PM Klaas de Waal <klaas.de.waal@gmail.com> wrote:
>
>> I have now added the support for the Services API along the same lines
>> as previously done for the bouquet_id and the region_id. It is
>> convenient to assume that the version bump done by Bill yesterday does
>> also cover this change.
>
> That change is necessary, as It provides the
> appropriate ability for a user (app) of the service
> API to identify when enable the new features.
>
> But that does not provide API backward
> compatibility when using an existing endpoint
> where existing codes which do not provide the
> values do not get existing values overridden by
> updates that do not provide them (likely using
> something like the checks that were mentioned
> by Roger to check if the names were supplied
> in the post, and if not, do not update those
> values in a row, or ensuring that existing values
> are maintained (depending on how you wish
> to write the code).
>
> If you are in progress with these changes I
> will just wait, but otherwise I can create a
> number of release blocker tickets so that
> v31 is not released prematurely. How do
> you wish to proceed?

For Channel/UpdateVideoSource, a fix was just pushed. And
thanks for the suggestions.

--
Bill
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Thu, Nov 28, 2019 at 11:19 PM Bill Meek <keemllib@gmail.com> wrote:

> For Channel/UpdateVideoSource, a fix was just pushed. And
> thanks for the suggestions.

Thanks for your fixes. It allowed me to not create
targeted reproducers and tickets. I will point out
it provides a negative reinforcement for me to
actually step up and do my part (i.e. you are
encouraging the slough in me).
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
I know I'm late to this discussion. My last week has been hectic.

On Sun, Nov 24, 2019 at 03:37:23PM +0000, Gary Buhrmaster wrote:
> On Sat, Nov 2, 2019 at 4:23 PM Klaas de Waal <klaas.de.waal@gmail.com> wrote:
>
> > I have now added the support for the Services API along the same lines
> > as previously done for the bouquet_id and the region_id. It is
> > convenient to assume that the version bump done by Bill yesterday does
> > also cover this change.
>
> That change is necessary, as It provides the
> appropriate ability for a user (app) of the service
> API to identify when enable the new features.
>
> But that does not provide API backward
> compatibility when using an existing endpoint
> where existing codes which do not provide the
> values do not get existing values overridden by
> updates that do not provide them (likely using
> something like the checks that were mentioned
> by Roger to check if the names were supplied
> in the post, and if not, do not update those
> values in a row, or ensuring that existing values
> are maintained (depending on how you wish
> to write the code).

I know the API layer allows for version numbers for each entry point.
Does anyone know if it also does for the abstract types too (i.e
VideoSource, Channel, etc.)? IMHO, for each entry point, we should
strive to support at least two versions -- the one for the current,
MythTV release and the one for the previous, MythTV release.

Does anyone know if (and how) the API layer allows for multiple
versions of the same entry points to be supported simultaneously?
I've not seen how to do it. If we don't have that capability, I
suggest we brute force it by appending the MythTV, major, version
number to anything that changes. For example, with the recent
buquet_id and region_id changes, any types and methods that were
changed would use a new, "31" suffix.

Note that I know virtually nothing of the API, layer internals and
maybe my suffix suggestion is too naive. The intent to support the
current and previous, API versions remains.

On Tue, Nov 26, 2019 at 01:43:27AM +0000, Gary Buhrmaster wrote:
> On Mon, Nov 25, 2019 at 6:22 AM Bill Meek <keemllib@gmail.com> wrote:
>
> > I *think* the attached is what Gary/Roger are suggesting. But when I
> > 'signed on', a senior developer said there shouldn't be any SQL in the
> > API code (but there was already.)
>
> (parenthetical comment: even senior devs can find
> that they have to make compromises in the real
> world unless they are one of the few with infinite
> time to refactor all the codes).
>
> That is one approach, another is to test for whether
> the value was provided (as Roger demonstrated in
> his reference), and, if not, do not update the columns
> (using conditional creation of the update SQL to not
> update columns not provided). Pseudo code follows.
>
> And so can creating an entirely new endpoint,
> although in this case I think that is overkill.
>
> Any of those can work, so it would depend on what
> makes sense as example going forward for other
> new devs who are not otherwise familiar with their
> requirements to maintain API compatibility (i.e.
> the added code, whatever it will be, will typically
> be copied for the next case).
>
> As this is a question for the devs (they will have
> to live with the solution going forward), I will defer
> to them to decide which is the best way to propose
> to fix the API breakage.
>
> pseudo code:
> // existing code (before new columns)
> QString updateSQL
> MSqlBindings bindings;
>
> updateSQL = "Update table .... set column1 = :Column1, column2 = :Column2"
> bindings[":Column1"] = Value1
> bindings[":Column2"] = Value2
>
> // Added code
> if (m_parsedParams.contains("RegionId"))
> updateSQL += " set regionid = :RegionId ";
> bindings[":RegionId"] = RegionId;

I like the idea of no SQL in the intermediate, API layers. It wasn't
me who suggested it earlier, though. Also, I don't think the update
only the chagned values will work in the general case. It might not
be possible to validate the changed values without knowing some of the
unchanged values too. I think the SQL read, merge changes and update
approach is best and should be done in the lowest, API layer. As has
been noted, we need some way of knowing what values are provided (and
which ones aren't) in the current invocation.

On Mon, Nov 25, 2019 at 08:00:32PM -0600, Bill Meek wrote:
> On 11/25/19 7:43 PM, Gary Buhrmaster wrote:
> > On Mon, Nov 25, 2019 at 6:22 AM Bill Meek <keemllib@gmail.com> wrote:
> >
> > > I *think* the attached is what Gary/Roger are suggesting. But when I
> > > 'signed on', a senior developer said there shouldn't be any SQL in the
> > > API code (but there was already.)
> >
> > (parenthetical comment: even senior devs can find
> > that they have to make compromises in the real
> > world unless they are one of the few with infinite
> > time to refactor all the codes).
> >
> > That is one approach, another is to test for whether
> > the value was provided (as Roger demonstrated in
> > his reference), and, if not, do not update the columns
> > (using conditional creation of the update SQL to not
> > update columns not provided). Pseudo code follows.
> >
> > And so can creating an entirely new endpoint,
> > although in this case I think that is overkill.
> >
> > Any of those can work, so it would depend on what
> > makes sense as example going forward for other
> > new devs who are not otherwise familiar with their
> > requirements to maintain API compatibility (i.e.
> > the added code, whatever it will be, will typically
> > be copied for the next case).
> >
> > As this is a question for the devs (they will have
> > to live with the solution going forward), I will defer
> > to them to decide which is the best way to propose
> > to fix the API breakage.
> >
> > pseudo code:
> > // existing code (before new columns)
> > QString updateSQL
> > MSqlBindings bindings;
> >
> > updateSQL = "Update table .... set column1 = :Column1, column2 = :Column2"
> > bindings[":Column1"] = Value1
> > bindings[":Column2"] = Value2
> >
> > // Added code
> > if (m_parsedParams.contains("RegionId"))
> > updateSQL += " set regionid = :RegionId ";
> > bindings[":RegionId"] = RegionId;
>
> Right, I'm using the m_parsedParms... solution. And in line SQL to get the existing values
> and the existing call to SourceUtil::UpdateSource(). Testing now.

What is this m_parsedParms? I seem to have missed it. Is it
something that states which paramerters are provided in an API
invocation?

Regarding knowing which parameters are provided, I'd previously
suggested using QVariants for everything. That would be messy, so I'm
now thinking a better idea might be to have the API layer pass a
QSet<QString> to each entry point with names of all provided
paramaters.

On Tue, Nov 26, 2019 at 02:31:12AM +0000, Gary Buhrmaster wrote:
> On Tue, Nov 26, 2019 at 2:01 AM Bill Meek <keemllib@gmail.com> wrote:
>
> > Fun fact: this endpoint broke mythfilldatabase if a user had a grabber
> > because the configpath gets set to "" rather than NULL. mythfilldatabase
> > depends on the NULL case to develop the path to the file automatically.
> > If ConfigPath=someValidPath, then it's OK.
>
> As I mentioned previously, there is a number
> of cases where NULL does not equal empty
> throughout the code base (sometimes for
> good reasons, some times I am not so sure),
> and the Services API generally does not
> provide a way to set a NULL and/or an
> empty value. Realistically there are only a
> few apps today that try to implement an
> alternative to mythtv-setup, so the impact is
> limited, but as I understand it the stated goal
> was to move towards a web based setup
> (using the services API), which makes the
> side cases more interesting to address.

I'm now thinking that in cases where NULL is ambiguous with
empty/0/whatever, we could use the convetion of having value or
valueIsNull paramerters where one or the other, but not both, is
present.

David
--
David Engel
david@istwok.net
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Mon, Dec 2, 2019 at 10:20 PM David Engel <david@istwok.net> wrote:

> Also, I don't think the update
> only the chagned values will work in the general case. It might not
> be possible to validate the changed values without knowing some of the
> unchanged values too.

To pile on a bit.....

It has been my experience that the
current services API, in some cases,
is fundamentally too low level, allowing
one (today) to set values that are (at
best) brain dead, and there is a lack
of business logic consistency applied
to the provided values (and in some
cases there is no way to apply the
proper business logic because those
relationships are not exposed for
add/updates (my pet example is creating
channels that require creation of a new
dtv_multiplexes, but you can't do that
(or you could not when I last checked))).

In essence, some of the API endpoints
are just fancy direct database updates,
with all the (dis)advantages of such.
My codes have had to try to implement
the business logic, and while I have
tried to read the relevant codes, it
could easily be incorrect, and whether
I would notice a change in business
logic in some MythTV commit is a
crap shoot. This feels excessively
fragile.

Unfortunately, I don't see an easy
way forward (all the ways I think
of require some significant resources).
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Mon, Dec 02, 2019 at 11:01:53PM +0000, Gary Buhrmaster wrote:
> On Mon, Dec 2, 2019 at 10:20 PM David Engel <david@istwok.net> wrote:
>
> > Also, I don't think the update
> > only the chagned values will work in the general case. It might not
> > be possible to validate the changed values without knowing some of the
> > unchanged values too.
>
> To pile on a bit.....
>
> It has been my experience that the
> current services API, in some cases,
> is fundamentally too low level, allowing
> one (today) to set values that are (at
> best) brain dead, and there is a lack
> of business logic consistency applied
> to the provided values (and in some
> cases there is no way to apply the
> proper business logic because those
> relationships are not exposed for
> add/updates (my pet example is creating
> channels that require creation of a new
> dtv_multiplexes, but you can't do that
> (or you could not when I last checked))).
>
> In essence, some of the API endpoints
> are just fancy direct database updates,
> with all the (dis)advantages of such.
> My codes have had to try to implement
> the business logic, and while I have
> tried to read the relevant codes, it
> could easily be incorrect, and whether
> I would notice a change in business
> logic in some MythTV commit is a
> crap shoot. This feels excessively
> fragile.

I agree.

> Unfortunately, I don't see an easy
> way forward (all the ways I think
> of require some significant resources).

All I can suggest is we should try to make things as generic and
abstract as we can. For example, the dtv_multiplex table should never
be directly visible in the API. It should be handled magically behind
the scenes through the channel updates. There are probably other tables
that should be handled similarly. diseqc tree, anyone?

Alas, I'm sure some APIs will have to remain very low-level. For
example, I don't ever expect the capture card handing(*) to really be
usable by anything except the built-in, web interface. Of course,
that's assuming someone eventually finds that round tuit.

David

(*)IMHO, those particular, service APIs should be disabled until they
are fixed. As currently constituted, they are very dangerous and
their use could easily lead to incorrect card configurations.

David
--
David Engel
david@istwok.net
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Mon, Dec 2, 2019 at 10:20 PM David Engel <david@istwok.net> wrote:

> I know the API layer allows for version numbers for each entry point.
> Does anyone know if it also does for the abstract types too (i.e
> VideoSource, Channel, etc.)? IMHO, for each entry point, we should
> strive to support at least two versions -- the one for the current,
> MythTV release and the one for the previous, MythTV release.

In some endpoint APIs in other projects the application
can send along the API they are using to a common
endpoint (ENDPOINT?API=1.2&var1=value1&var2=value2)
and in other projects the URL itself has the version
(.../V1.2/ENDPOINT?var1=value1&var2=value2). I
have no specific preference, but supporting more
than one endpoint version is important to provide
applications transition periods if one is to claim
API compatibility for more than just "master". If I
had a vote (and I fully understand I do not), "latest"
and "master" compatibility should be required in
"master", and "latest" and "latest-1" for the release
of "latest".

As with all else, there are certain edge cases where
that is not going to be possible. But in my experience
if you make it a requirement the developers figure
out a way rather than admit they are not good enough
to make it so.

FWIW, the external recorder supports a version
negotiation process to support an upgrade transition.
It is not the same as the services API, but it
demonstrates a (mostly) seamless transition
to new capabilities while supporting the old,
and I definitely appreciated the work Mr. Poet
made to make that transition viable without a
flag day.
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Services API for ChannelServices / Channel [ In reply to ]
On Mon, 2 Dec 2019 16:19:15 -0600
David Engel <david@istwok.net> wrote:

> I know I'm late to this discussion. My last week has been hectic.
>
Not as late as me.

> I know the API layer allows for version numbers for each entry point.
> Does anyone know if it also does for the abstract types too (i.e
> VideoSource, Channel, etc.)? IMHO, for each entry point, we should
> strive to support at least two versions -- the one for the current,
> MythTV release and the one for the previous, MythTV release.
>
> Does anyone know if (and how) the API layer allows for multiple
> versions of the same entry points to be supported simultaneously?
> I've not seen how to do it. If we don't have that capability, I
> suggest we brute force it by appending the MythTV, major, version
> number to anything that changes. For example, with the recent
> buquet_id and region_id changes, any types and methods that were
> changed would use a new, "31" suffix.
>

Adding version numbers is a bad idea - we don't want to convert the
services back into a re-implementation of MythProtocol.

A backend only implements a single version (the latest) of an
entry-point, i.e mythbackend.30 implements v1.6 of the Channel
entry-point whilst mythbackend.31 will, seemingly, implement v1.7.

All endpoints of the service should be backwardly-compatible, but that's
easier than you think.

The pertinent point is that MythProtocol is designed for binary data -
it is impossible to decode anything without the encoding version/schema.
Whereas REST services work with structured data (JSON/XML/HTTP)
- extract whatever you know about and safely ignore the rest.

Therefore the version number actually specifies the minimum set of data
present; extra (unintelligible) data from later versions is ignored. For
backend endpoints that will manifest as receiving extra, unknown http
args. For clients, some parts of the JSON result won't be parsed.

Thus the golden rule of services: Removing (or renaming) existing
parameters/fields will break backward-compatibility
(a major version change). But adding new ones is fine.

Note I'm not entirely clear where bouquet fits in - I'm assuming its a
new channel property.

So, add bouquet_id etc. to ChannelInfo(?) & bump
the minor version. Follow Paul's example:
https://github.com/MythTV/mythtv/commit/63a5a20ec2b1ce908f99ffcc55eb65adfae575f2

There are functional considerations, which translates as: Don't assume
the client is speaking the same version. Usually that means new
parameters should be optional with sensible defaults, and retain old
behaviour.

The backend advertises its service version
({backend_ip}/Channel/version). But an endpoint can't know what version
the client is using (multiple clients may use different versions).
Therefore it's up to the client to negotiate/downgrade to the backend
version, or suffer the consequences.

Suppose I have 2 backends & 2 clients:
- be6 (running myth.30, providing Channel service 1.6)
- be7 (running myth.31, providing Channel service 1.7)
- client6 (using Channel service 1.6)
- client7 (using Channel service 1.7)

Hopefully client6/be6 & client7/be7 work as expected!

With client6/be7, the client will be ignorant of any bouquet_id the
backend emits and so will never return it as an HTTP arg. Is the request
now invalid ? But it works ok with be6! So a backend endpoint should
fallback to old (be6) behaviour if bouquet_id isn't supplied.

With client7/be6, the backend will be ignorant of any bouquet_id the
client specifies, so may deduce its own. That might surprise the client,
but it shouldn't be so ignorant as to use version 1.7 parameters with
a 1.6 service.

> What is this m_parsedParms? I seem to have missed it. Is it
> something that states which paramerters are provided in an API
> invocation?
>
Yes. It arose from a thread on the developers list 05/Mar/17, "Add
method to update the metadata for a video using the ServicesAPI"
http://lists.mythtv.org/mailman/private/mythtv-developers/2017-March/005721.html

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org