Skip to content

Commit af962d1

Browse files
committed
Add models for Alexa Presentation Language
1 parent 704ba36 commit af962d1

30 files changed

+2016
-10
lines changed

ask-sdk-model/CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ CHANGELOG
5050

5151
* Models for "PrintRequest" and "ReservationRequest" in Skill Connections.
5252

53+
1.3.0
54+
~~~~~
55+
56+
* Models for "Alexa Presentation Language". The Alexa Presentation Language
57+
(APL) enables you to build interactive voice experiences that include
58+
graphics, images, slideshows, and video, and to customize them for
59+
different device types.
60+

ask-sdk-model/ask_sdk_model/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
__pip_package_name__ = 'ask-sdk-model'
1515
__description__ = 'The ASK SDK Model package provides model definitions, for building Alexa Skills.'
1616
__url__ = 'https://github.com/alexa/alexa-apis-for-python'
17-
__version__ = '1.2.0'
17+
__version__ = '1.3.0'
1818
__author__ = 'Alexa Skills Kit'
1919
__author_email__ = 'ask-sdk-dynamic@amazon.com'
2020
__license__ = 'Apache 2.0'

ask-sdk-model/ask_sdk_model/context.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from datetime import datetime
2626
from ask_sdk_model.interfaces.system.system_state import SystemState
2727
from ask_sdk_model.interfaces.audioplayer.audio_player_state import AudioPlayerState
28+
from ask_sdk_model.interfaces.viewport.viewport_state import ViewportState
2829
from ask_sdk_model.interfaces.display.display_state import DisplayState
2930

3031

@@ -37,22 +38,26 @@ class Context(object):
3738
:type audio_player: (optional) ask_sdk_model.interfaces.audioplayer.audio_player_state.AudioPlayerState
3839
:param display: Provides the current state for the Display interface.
3940
:type display: (optional) ask_sdk_model.interfaces.display.display_state.DisplayState
41+
:param viewport: Provides the characteristics of a device's viewport.
42+
:type viewport: (optional) ask_sdk_model.interfaces.viewport.viewport_state.ViewportState
4043
4144
"""
4245
deserialized_types = {
4346
'system': 'ask_sdk_model.interfaces.system.system_state.SystemState',
4447
'audio_player': 'ask_sdk_model.interfaces.audioplayer.audio_player_state.AudioPlayerState',
45-
'display': 'ask_sdk_model.interfaces.display.display_state.DisplayState'
48+
'display': 'ask_sdk_model.interfaces.display.display_state.DisplayState',
49+
'viewport': 'ask_sdk_model.interfaces.viewport.viewport_state.ViewportState'
4650
}
4751

4852
attribute_map = {
4953
'system': 'System',
5054
'audio_player': 'AudioPlayer',
51-
'display': 'Display'
55+
'display': 'Display',
56+
'viewport': 'Viewport'
5257
}
5358

54-
def __init__(self, system=None, audio_player=None, display=None):
55-
# type: (Optional[SystemState], Optional[AudioPlayerState], Optional[DisplayState]) -> None
59+
def __init__(self, system=None, audio_player=None, display=None, viewport=None):
60+
# type: (Optional[SystemState], Optional[AudioPlayerState], Optional[DisplayState], Optional[ViewportState]) -> None
5661
"""
5762
5863
:param system: Provides information about the current state of the Alexa service and the device interacting with your skill.
@@ -61,12 +66,15 @@ def __init__(self, system=None, audio_player=None, display=None):
6166
:type audio_player: (optional) ask_sdk_model.interfaces.audioplayer.audio_player_state.AudioPlayerState
6267
:param display: Provides the current state for the Display interface.
6368
:type display: (optional) ask_sdk_model.interfaces.display.display_state.DisplayState
69+
:param viewport: Provides the characteristics of a device's viewport.
70+
:type viewport: (optional) ask_sdk_model.interfaces.viewport.viewport_state.ViewportState
6471
"""
6572
self.__discriminator_value = None
6673

6774
self.system = system
6875
self.audio_player = audio_player
6976
self.display = display
77+
self.viewport = viewport
7078

7179
def to_dict(self):
7280
# type: () -> Dict[str, object]

ask-sdk-model/ask_sdk_model/directive.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class Directive(object):
4343
|
4444
| AudioPlayer.Play: :py:class:`ask_sdk_model.interfaces.audioplayer.play_directive.PlayDirective`,
4545
|
46+
| Alexa.Presentation.APL.ExecuteCommands: :py:class:`ask_sdk_model.interfaces.alexa.presentation.apl.execute_commands_directive.ExecuteCommandsDirective`,
47+
|
4648
| Connections.SendRequest: :py:class:`ask_sdk_model.interfaces.connections.send_request_directive.SendRequestDirective`,
4749
|
4850
| Display.RenderTemplate: :py:class:`ask_sdk_model.interfaces.display.render_template_directive.RenderTemplateDirective`,
@@ -61,6 +63,8 @@ class Directive(object):
6163
|
6264
| GameEngine.StopInputHandler: :py:class:`ask_sdk_model.interfaces.game_engine.stop_input_handler_directive.StopInputHandlerDirective`,
6365
|
66+
| Alexa.Presentation.APL.RenderDocument: :py:class:`ask_sdk_model.interfaces.alexa.presentation.apl.render_document_directive.RenderDocumentDirective`,
67+
|
6468
| Connections.SendResponse: :py:class:`ask_sdk_model.interfaces.connections.send_response_directive.SendResponseDirective`,
6569
|
6670
| Dialog.ElicitSlot: :py:class:`ask_sdk_model.dialog.elicit_slot_directive.ElicitSlotDirective`,
@@ -80,6 +84,7 @@ class Directive(object):
8084
'AudioPlayer.Stop': 'ask_sdk_model.interfaces.audioplayer.stop_directive.StopDirective',
8185
'Dialog.ConfirmSlot': 'ask_sdk_model.dialog.confirm_slot_directive.ConfirmSlotDirective',
8286
'AudioPlayer.Play': 'ask_sdk_model.interfaces.audioplayer.play_directive.PlayDirective',
87+
'Alexa.Presentation.APL.ExecuteCommands': 'ask_sdk_model.interfaces.alexa.presentation.apl.execute_commands_directive.ExecuteCommandsDirective',
8388
'Connections.SendRequest': 'ask_sdk_model.interfaces.connections.send_request_directive.SendRequestDirective',
8489
'Display.RenderTemplate': 'ask_sdk_model.interfaces.display.render_template_directive.RenderTemplateDirective',
8590
'GadgetController.SetLight': 'ask_sdk_model.interfaces.gadget_controller.set_light_directive.SetLightDirective',
@@ -89,6 +94,7 @@ class Directive(object):
8994
'GameEngine.StartInputHandler': 'ask_sdk_model.interfaces.game_engine.start_input_handler_directive.StartInputHandlerDirective',
9095
'VideoApp.Launch': 'ask_sdk_model.interfaces.videoapp.launch_directive.LaunchDirective',
9196
'GameEngine.StopInputHandler': 'ask_sdk_model.interfaces.game_engine.stop_input_handler_directive.StopInputHandlerDirective',
97+
'Alexa.Presentation.APL.RenderDocument': 'ask_sdk_model.interfaces.alexa.presentation.apl.render_document_directive.RenderDocumentDirective',
9298
'Connections.SendResponse': 'ask_sdk_model.interfaces.connections.send_response_directive.SendResponseDirective',
9399
'Dialog.ElicitSlot': 'ask_sdk_model.dialog.elicit_slot_directive.ElicitSlotDirective',
94100
'AudioPlayer.ClearQueue': 'ask_sdk_model.interfaces.audioplayer.clear_queue_directive.ClearQueueDirective'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the 'License'). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
from __future__ import absolute_import
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the 'License'). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
from __future__ import absolute_import
16+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the 'License'). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
from __future__ import absolute_import
16+
17+
from .alexa_presentation_apl_interface import AlexaPresentationAplInterface
18+
from .align import Align
19+
from .auto_page_command import AutoPageCommand
20+
from .command import Command
21+
from .execute_commands_directive import ExecuteCommandsDirective
22+
from .highlight_mode import HighlightMode
23+
from .position import Position
24+
from .render_document_directive import RenderDocumentDirective
25+
from .runtime import Runtime
26+
from .set_page_command import SetPageCommand
27+
from .speak_item_command import SpeakItemCommand
28+
from .user_event import UserEvent
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
22+
23+
if typing.TYPE_CHECKING:
24+
from typing import Dict, List, Optional
25+
from datetime import datetime
26+
from ask_sdk_model.interfaces.alexa.presentation.apl.runtime import Runtime
27+
28+
29+
class AlexaPresentationAplInterface(object):
30+
"""
31+
32+
:param runtime:
33+
:type runtime: (optional) ask_sdk_model.interfaces.alexa.presentation.apl.runtime.Runtime
34+
35+
"""
36+
deserialized_types = {
37+
'runtime': 'ask_sdk_model.interfaces.alexa.presentation.apl.runtime.Runtime'
38+
}
39+
40+
attribute_map = {
41+
'runtime': 'runtime'
42+
}
43+
44+
def __init__(self, runtime=None):
45+
# type: (Optional[Runtime]) -> None
46+
"""
47+
48+
:param runtime:
49+
:type runtime: (optional) ask_sdk_model.interfaces.alexa.presentation.apl.runtime.Runtime
50+
"""
51+
self.__discriminator_value = None
52+
53+
self.runtime = runtime
54+
55+
def to_dict(self):
56+
# type: () -> Dict[str, object]
57+
"""Returns the model properties as a dict"""
58+
result = {}
59+
60+
for attr, _ in six.iteritems(self.deserialized_types):
61+
value = getattr(self, attr)
62+
if isinstance(value, list):
63+
result[attr] = list(map(
64+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
65+
x.value if isinstance(x, Enum) else x,
66+
value
67+
))
68+
elif isinstance(value, Enum):
69+
result[attr] = value.value
70+
elif hasattr(value, "to_dict"):
71+
result[attr] = value.to_dict()
72+
elif isinstance(value, dict):
73+
result[attr] = dict(map(
74+
lambda item: (item[0], item[1].to_dict())
75+
if hasattr(item[1], "to_dict") else
76+
(item[0], item[1].value)
77+
if isinstance(item[1], Enum) else item,
78+
value.items()
79+
))
80+
else:
81+
result[attr] = value
82+
83+
return result
84+
85+
def to_str(self):
86+
# type: () -> str
87+
"""Returns the string representation of the model"""
88+
return pprint.pformat(self.to_dict())
89+
90+
def __repr__(self):
91+
# type: () -> str
92+
"""For `print` and `pprint`"""
93+
return self.to_str()
94+
95+
def __eq__(self, other):
96+
# type: (object) -> bool
97+
"""Returns true if both objects are equal"""
98+
if not isinstance(other, AlexaPresentationAplInterface):
99+
return False
100+
101+
return self.__dict__ == other.__dict__
102+
103+
def __ne__(self, other):
104+
# type: (object) -> bool
105+
"""Returns true if both objects are not equal"""
106+
return not self == other
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
22+
23+
if typing.TYPE_CHECKING:
24+
from typing import Dict, List, Optional
25+
from datetime import datetime
26+
27+
28+
class Align(Enum):
29+
"""
30+
The alignment of the item after scrolling. Defaults to visible.
31+
32+
33+
34+
Allowed enum values: [CENTER, FIRST, LAST, VISIBLE]
35+
"""
36+
CENTER = "CENTER"
37+
FIRST = "FIRST"
38+
LAST = "LAST"
39+
VISIBLE = "VISIBLE"
40+
def to_dict(self):
41+
# type: () -> Dict[str, object]
42+
"""Returns the model properties as a dict"""
43+
result = {self.name: self.value}
44+
return result
45+
46+
def to_str(self):
47+
# type: () -> str
48+
"""Returns the string representation of the model"""
49+
return pprint.pformat(self.value)
50+
51+
def __repr__(self):
52+
# type: () -> str
53+
"""For `print` and `pprint`"""
54+
return self.to_str()
55+
56+
def __eq__(self, other):
57+
# type: (object) -> bool
58+
"""Returns true if both objects are equal"""
59+
if not isinstance(other, Align):
60+
return False
61+
62+
return self.__dict__ == other.__dict__
63+
64+
def __ne__(self, other):
65+
# type: (object) -> bool
66+
"""Returns true if both objects are not equal"""
67+
return not self == other

0 commit comments

Comments
 (0)