besapi 3.2.2__tar.gz → 3.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: besapi
3
- Version: 3.2.2
3
+ Version: 3.2.6
4
4
  Summary: Library for working with the BigFix REST API
5
5
  Home-page: https://github.com/jgstew/besapi
6
6
  Author: Matt Hansen, James Stewart
@@ -29,7 +29,7 @@ import requests
29
29
  from lxml import etree, objectify
30
30
  from pkg_resources import resource_filename
31
31
 
32
- __version__ = "3.2.2"
32
+ __version__ = "3.2.6"
33
33
 
34
34
  besapi_logger = logging.getLogger("besapi")
35
35
 
@@ -393,6 +393,34 @@ class BESConnection:
393
393
  self.session.cookies.clear()
394
394
  self.session.close()
395
395
 
396
+ def set_dashboard_variable_value(
397
+ self, dashboard_name, var_name, var_value, private=False
398
+ ):
399
+ """set the variable value from a dashboard datastore"""
400
+
401
+ dash_var_xml = f"""<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
402
+ <DashboardData>
403
+ <Dashboard>{dashboard_name}</Dashboard>
404
+ <Name>{var_name}</Name>
405
+ <IsPrivate>{str(private).lower()}</IsPrivate>
406
+ <Value>{var_value}</Value>
407
+ </DashboardData>
408
+ </BESAPI>
409
+ """
410
+
411
+ return self.post(
412
+ f"dashboardvariable/{dashboard_name}/{var_name}", data=dash_var_xml
413
+ )
414
+
415
+ def get_dashboard_variable_value(self, dashboard_name, var_name):
416
+ """get the variable value from a dashboard datastore"""
417
+
418
+ return str(
419
+ self.get(
420
+ f"dashboardvariable/{dashboard_name}/{var_name}"
421
+ ).besobj.DashboardData.Value
422
+ )
423
+
396
424
  def validate_site_path(self, site_path, check_site_exists=True, raise_error=False):
397
425
  """make sure site_path is valid"""
398
426
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: besapi
3
- Version: 3.2.2
3
+ Version: 3.2.6
4
4
  Summary: Library for working with the BigFix REST API
5
5
  Home-page: https://github.com/jgstew/besapi
6
6
  Author: Matt Hansen, James Stewart
@@ -5,6 +5,7 @@ Test besapi
5
5
 
6
6
  import argparse
7
7
  import os
8
+ import random
8
9
  import subprocess
9
10
  import sys
10
11
 
@@ -128,6 +129,20 @@ if bigfix_cli.bes_conn:
128
129
  assert "test_besapi_upload.txt</URL>" in str(upload_result)
129
130
  print(bigfix_cli.bes_conn.parse_upload_result_to_prefetch(upload_result))
130
131
 
132
+ dashboard_name = "_PyBESAPI_tests.py"
133
+ var_name = "TestVarName"
134
+ var_value = "TestVarValue " + str(random.randint(0, 9999))
135
+
136
+ print(
137
+ bigfix_cli.bes_conn.set_dashboard_variable_value(
138
+ dashboard_name, var_name, var_value
139
+ )
140
+ )
141
+
142
+ assert var_value in str(
143
+ bigfix_cli.bes_conn.get_dashboard_variable_value(dashboard_name, var_name)
144
+ )
145
+
131
146
  if os.name == "nt":
132
147
  subprocess.run(
133
148
  'CMD /C python -m besapi ls clear ls conf "query number of bes computers" version error_count exit',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes