Skip to content

Commit 905821b

Browse files
author
ask-pyth
committed
Release 1.11.0. For changelog, check CHANGELOG.rst
1 parent 153f406 commit 905821b

File tree

5 files changed

+158
-1
lines changed

5 files changed

+158
-1
lines changed

ask-sdk-model/CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,12 @@ This release contains the following changes:
168168

169169
- Fix the `deserialized_type` for viewport_state.video object
170170

171+
172+
173+
1.11.0
174+
~~~~~~~
175+
176+
This release contains the following changes :
177+
178+
- APL `SetValue <https://developer.amazon.com/docs/alexa-presentation-language/apl-standard-commands.html#setvalue-command>`__ command support.
179+

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.10.3'
17+
__version__ = '1.11.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/interfaces/alexa/presentation/apl/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .render_document_directive import RenderDocumentDirective
2222
from .audio_track import AudioTrack
2323
from .parallel_command import ParallelCommand
24+
from .set_value_command import SetValueCommand
2425
from .scroll_command import ScrollCommand
2526
from .auto_page_command import AutoPageCommand
2627
from .speak_item_command import SpeakItemCommand

ask-sdk-model/ask_sdk_model/interfaces/alexa/presentation/apl/command.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class Command(object):
6767
|
6868
| Idle: :py:class:`ask_sdk_model.interfaces.alexa.presentation.apl.idle_command.IdleCommand`,
6969
|
70+
| SetValue: :py:class:`ask_sdk_model.interfaces.alexa.presentation.apl.set_value_command.SetValueCommand`,
71+
|
7072
| SendEvent: :py:class:`ask_sdk_model.interfaces.alexa.presentation.apl.send_event_command.SendEventCommand`,
7173
|
7274
| SpeakList: :py:class:`ask_sdk_model.interfaces.alexa.presentation.apl.speak_list_command.SpeakListCommand`
@@ -98,6 +100,7 @@ class Command(object):
98100
'ScrollToIndex': 'ask_sdk_model.interfaces.alexa.presentation.apl.scroll_to_index_command.ScrollToIndexCommand',
99101
'Scroll': 'ask_sdk_model.interfaces.alexa.presentation.apl.scroll_command.ScrollCommand',
100102
'Idle': 'ask_sdk_model.interfaces.alexa.presentation.apl.idle_command.IdleCommand',
103+
'SetValue': 'ask_sdk_model.interfaces.alexa.presentation.apl.set_value_command.SetValueCommand',
101104
'SendEvent': 'ask_sdk_model.interfaces.alexa.presentation.apl.send_event_command.SendEventCommand',
102105
'SpeakList': 'ask_sdk_model.interfaces.alexa.presentation.apl.speak_list_command.SpeakListCommand'
103106
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2019 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+
from ask_sdk_model.interfaces.alexa.presentation.apl.command import Command
22+
23+
24+
if typing.TYPE_CHECKING:
25+
from typing import Dict, List, Optional
26+
from datetime import datetime
27+
28+
29+
class SetValueCommand(Command):
30+
"""
31+
Change a dynamic property of a component without redrawing the screen.
32+
33+
34+
:param delay: The delay in milliseconds before this command starts executing; must be non-negative. Defaults to 0.
35+
:type delay: (optional) int
36+
:param description: A user-provided description of this command.
37+
:type description: (optional) str
38+
:param when: If false, the execution of the command is skipped. Defaults to true.
39+
:type when: (optional) bool
40+
:param component_id: The id of the component whose value to set.
41+
:type component_id: (optional) str
42+
:param object_property: The name of the property to set.
43+
:type object_property: (optional) str
44+
:param value: The property value to set.
45+
:type value: (optional) str
46+
47+
"""
48+
deserialized_types = {
49+
'object_type': 'str',
50+
'delay': 'int',
51+
'description': 'str',
52+
'when': 'bool',
53+
'component_id': 'str',
54+
'object_property': 'str',
55+
'value': 'str'
56+
} # type: Dict
57+
58+
attribute_map = {
59+
'object_type': 'type',
60+
'delay': 'delay',
61+
'description': 'description',
62+
'when': 'when',
63+
'component_id': 'componentId',
64+
'object_property': 'property',
65+
'value': 'value'
66+
} # type: Dict
67+
68+
def __init__(self, delay=None, description=None, when=None, component_id=None, object_property=None, value=None):
69+
# type: (Optional[int], Optional[str], Optional[bool], Optional[str], Optional[str], Optional[str]) -> None
70+
"""Change a dynamic property of a component without redrawing the screen.
71+
72+
:param delay: The delay in milliseconds before this command starts executing; must be non-negative. Defaults to 0.
73+
:type delay: (optional) int
74+
:param description: A user-provided description of this command.
75+
:type description: (optional) str
76+
:param when: If false, the execution of the command is skipped. Defaults to true.
77+
:type when: (optional) bool
78+
:param component_id: The id of the component whose value to set.
79+
:type component_id: (optional) str
80+
:param object_property: The name of the property to set.
81+
:type object_property: (optional) str
82+
:param value: The property value to set.
83+
:type value: (optional) str
84+
"""
85+
self.__discriminator_value = "SetValue" # type: str
86+
87+
self.object_type = self.__discriminator_value
88+
super(SetValueCommand, self).__init__(object_type=self.__discriminator_value, delay=delay, description=description, when=when)
89+
self.component_id = component_id
90+
self.object_property = object_property
91+
self.value = value
92+
93+
def to_dict(self):
94+
# type: () -> Dict[str, object]
95+
"""Returns the model properties as a dict"""
96+
result = {} # type: Dict
97+
98+
for attr, _ in six.iteritems(self.deserialized_types):
99+
value = getattr(self, attr)
100+
if isinstance(value, list):
101+
result[attr] = list(map(
102+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
103+
x.value if isinstance(x, Enum) else x,
104+
value
105+
))
106+
elif isinstance(value, Enum):
107+
result[attr] = value.value
108+
elif hasattr(value, "to_dict"):
109+
result[attr] = value.to_dict()
110+
elif isinstance(value, dict):
111+
result[attr] = dict(map(
112+
lambda item: (item[0], item[1].to_dict())
113+
if hasattr(item[1], "to_dict") else
114+
(item[0], item[1].value)
115+
if isinstance(item[1], Enum) else item,
116+
value.items()
117+
))
118+
else:
119+
result[attr] = value
120+
121+
return result
122+
123+
def to_str(self):
124+
# type: () -> str
125+
"""Returns the string representation of the model"""
126+
return pprint.pformat(self.to_dict())
127+
128+
def __repr__(self):
129+
# type: () -> str
130+
"""For `print` and `pprint`"""
131+
return self.to_str()
132+
133+
def __eq__(self, other):
134+
# type: (object) -> bool
135+
"""Returns true if both objects are equal"""
136+
if not isinstance(other, SetValueCommand):
137+
return False
138+
139+
return self.__dict__ == other.__dict__
140+
141+
def __ne__(self, other):
142+
# type: (object) -> bool
143+
"""Returns true if both objects are not equal"""
144+
return not self == other

0 commit comments

Comments
 (0)