besapi 3.2.1__tar.gz → 3.2.4__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.1
3
+ Version: 3.2.4
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
@@ -1,5 +1,5 @@
1
1
  [metadata]
2
- version = attr: besapi.__version__
2
+ version = attr: besapi.besapi.__version__
3
3
  long_description = file: README.md
4
4
  long_description_content_type = text/markdown
5
5
  classifiers =
@@ -5,5 +5,3 @@ besapi is a python module for interacting with the BigFix REST API
5
5
  # https://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path/4397291
6
6
 
7
7
  from . import besapi
8
-
9
- __version__ = "3.2.1"
@@ -1,6 +1,10 @@
1
1
  """
2
2
  To run this module directly
3
3
  """
4
+
5
+ import logging
6
+
4
7
  from bescli import bescli
5
8
 
9
+ logging.basicConfig()
6
10
  bescli.main()
@@ -29,6 +29,8 @@ import requests
29
29
  from lxml import etree, objectify
30
30
  from pkg_resources import resource_filename
31
31
 
32
+ __version__ = "3.2.4"
33
+
32
34
  besapi_logger = logging.getLogger("besapi")
33
35
 
34
36
 
@@ -350,7 +352,9 @@ class BESConnection:
350
352
 
351
353
  def session_relevance_string(self, relevance, **kwargs):
352
354
  """Get Session Relevance Results string"""
353
- rel_result_array = self.session_relevance_array(relevance, **kwargs)
355
+ rel_result_array = self.session_relevance_array(
356
+ "(it as string) of " + relevance, **kwargs
357
+ )
354
358
  return "\n".join(rel_result_array)
355
359
 
356
360
  def login(self):
@@ -389,6 +393,34 @@ class BESConnection:
389
393
  self.session.cookies.clear()
390
394
  self.session.close()
391
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
+
392
424
  def validate_site_path(self, site_path, check_site_exists=True, raise_error=False):
393
425
  """make sure site_path is valid"""
394
426
 
@@ -999,4 +1031,5 @@ def main():
999
1031
 
1000
1032
 
1001
1033
  if __name__ == "__main__":
1034
+ logging.basicConfig()
1002
1035
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: besapi
3
- Version: 3.2.1
3
+ Version: 3.2.4
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
@@ -1,6 +1,7 @@
1
1
  """
2
2
  bescli provides a command line interface to interact with besapi
3
3
  """
4
+
4
5
  # https://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path/4397291
5
6
 
6
7
  from . import bescli
@@ -1,6 +1,10 @@
1
1
  """
2
2
  To run this module directly
3
3
  """
4
+
5
+ import logging
6
+
4
7
  from . import bescli
5
8
 
9
+ logging.basicConfig()
6
10
  bescli.main()
@@ -28,7 +28,10 @@ except ImportError:
28
28
  # this is for the case in which we are calling bescli from besapi
29
29
  import besapi
30
30
 
31
- from besapi import __version__
31
+ try:
32
+ from besapi.besapi import __version__
33
+ except ImportError:
34
+ from besapi import __version__
32
35
 
33
36
 
34
37
  class BESCLInterface(Cmd):
@@ -421,4 +424,5 @@ def main():
421
424
 
422
425
 
423
426
  if __name__ == "__main__":
427
+ logging.basicConfig()
424
428
  main()
@@ -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
 
@@ -25,7 +26,7 @@ if not args.test_pip:
25
26
 
26
27
  import besapi
27
28
 
28
- print("besapi version: " + str(besapi.__version__))
29
+ print("besapi version: " + str(besapi.besapi.__version__))
29
30
 
30
31
  assert 15 == len(besapi.besapi.rand_password(15))
31
32
 
@@ -124,9 +125,24 @@ if bigfix_cli.bes_conn:
124
125
  upload_result = bigfix_cli.bes_conn.upload(
125
126
  "./besapi/__init__.py", "test_besapi_upload.txt"
126
127
  )
127
- print(upload_result)
128
+ # print(upload_result)
129
+ assert "test_besapi_upload.txt</URL>" in str(upload_result)
128
130
  print(bigfix_cli.bes_conn.parse_upload_result_to_prefetch(upload_result))
129
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
+
130
146
  if os.name == "nt":
131
147
  subprocess.run(
132
148
  'CMD /C python -m besapi ls clear ls conf "query number of bes computers" version error_count exit',
@@ -134,3 +150,5 @@ if bigfix_cli.bes_conn:
134
150
  )
135
151
  bes_conn = besapi.besapi.get_bes_conn_using_config_file()
136
152
  print("login succeeded:", bes_conn.login())
153
+
154
+ sys.exit(0)
File without changes
File without changes
File without changes
File without changes
File without changes