Skip to content

Commit 068a13d

Browse files
update name/value to key/value for Metadata
1 parent 68fee91 commit 068a13d

File tree

4 files changed

+38
-37
lines changed

4 files changed

+38
-37
lines changed

python-examples/basic/basic_send_complex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162

163163
# Add Metadata using the add_metadata function
164164
message.add_tag("I am a test message")
165+
message.add_tag("python-Example")
165166

166167
# get credentials from environment variables
167168
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))

python-examples/bulk/bulk_send_complex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201

202202
# Add Metadata using the add_metadata function
203203
message.add_tag("I am a test message")
204+
message.add_tag("python-Example")
204205

205206
# get credentials from environment variables
206207
server_id = int(os.environ.get('SOCKETLABS_SERVER_ID'))

socketlabs/injectionapi/core/serialization/metadatajson.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
class MetadataJson(object):
22
"""
3-
Represents a metadata as a name and value pair.
3+
Represents a metadata as a key and value pair.
44
To be serialized into JSON string before sending to the Injection Api.
55
"""
66

7-
def __init__(self, name: str = None, val: str = None):
7+
def __init__(self, key: str = None, val: str = None):
88
"""
99
Initializes a new instance of the MetadataJson class
10-
:param name: the name of the metadata
11-
:type name: str
10+
:param key: the key of the metadata
11+
:type key: str
1212
:param val: the value of the metadata
1313
:type val: str
1414
"""
15-
self._name = name
15+
self._key = key
1616
self._value = val
1717

1818
@property
19-
def name(self):
19+
def key(self):
2020
"""
21-
The name of the metadata.
22-
:return the name
21+
The key of the metadata.
22+
:return the key
2323
:rtype str
2424
"""
25-
return str(self._name)
25+
return str(self._key)
2626

27-
@name.setter
28-
def name(self, val: str):
27+
@key.setter
28+
def key(self, val: str):
2929
"""
30-
Set the name of the metadata.
31-
:param val: the name
32-
:type val: str
30+
Set the key of the metadata.
31+
key :type val: str
3332
"""
34-
self._name = val
33+
self._key = val
3534

3635
@property
3736
def value(self):
@@ -58,6 +57,6 @@ def to_json(self):
5857
:rtype dict
5958
"""
6059
return {
61-
"name": self._name,
60+
"key": self._key,
6261
"value": self._value
6362
}

socketlabs/injectionapi/message/metadata.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@
33

44
class Metadata(object):
55
"""
6-
Represents a metadata as a name-value pair.
6+
Represents a metadata as a key-value pair.
77
88
:Example:
99
1010
metadata1 = Metadata()
11-
metadata1.name = "name1"
11+
metadata1.key = "key1"
1212
metadata1.value = "value1"
1313
14-
metadata2 = Metadata("name1", "value1")
14+
metadata2 = Metadata("key1", "value1")
1515
1616
"""
1717

18-
def __init__(self, name: str = None, val: str = None):
18+
def __init__(self, key: str = None, val: str = None):
1919
"""
2020
Initializes a new instance of the Metadata class
21-
:param name: the name of the metadata
22-
:type name: str
21+
:param key: the key of the metadata
22+
:type key: str
2323
:param val: the value of the metadata
2424
:type val: str
2525
"""
26-
self._name = name
26+
self._key = key
2727
self._value = val
2828

2929
@property
30-
def name(self):
30+
def key(self):
3131
"""
32-
Get the name
33-
:return the name
32+
Get the key
33+
:return the key
3434
:rtype str
3535
"""
36-
return str(self._name)
36+
return str(self._key)
3737

38-
@name.setter
39-
def name(self, val: str):
38+
@key.setter
39+
def key(self, val: str):
4040
"""
41-
Set the name
42-
:param val: the name
41+
Set the key
42+
:param val: the key
4343
:type val: str
4444
"""
45-
self._name = val
45+
self._key = val
4646

4747
@property
4848
def value(self):
@@ -68,16 +68,16 @@ def isvalid(self):
6868
:return the result
6969
:rtype bool
7070
"""
71-
validName = not StringExtension.is_none_or_white_space(self._name)
72-
validValue = not StringExtension.is_none_or_white_space(self._value)
73-
if validName and validValue:
71+
validkey = not StringExtension.is_none_or_white_space(self._key)
72+
validvalue = not StringExtension.is_none_or_white_space(self._value)
73+
if validkey and validvalue:
7474
return True
7575
return False
7676

7777
def __str__(self):
7878
"""
79-
Represents the Metadata name-value pair as a string
79+
Represents the Metadata key-value pair as a string
8080
:return the string
8181
:rtype str
8282
"""
83-
return str(self._name + ", " + self._value)
83+
return str(self._key + ", " + self._value)

0 commit comments

Comments
 (0)