summaryrefslogtreecommitdiff
path: root/python-tdxlib.spec
blob: 7f8392ffbd77f9545b49a7b6018e42bc6835e66f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
%global _empty_manifest_terminate_build 0
Name:		python-TDXLib
Version:	0.4.3
Release:	1
Summary:	a python library for interacting with the TeamDynamix Web API
License:	GNU General Public License v3.0
URL:		https://github.com/cedarville-university/tdxlib
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/2c/94/a83974f1a6cd7bf290bdfd1c1c858a89ce10f743fdce69722ada0c06eb30/TDXLib-0.4.3.tar.gz
BuildArch:	noarch

Requires:	python3-dateutil
Requires:	python3-requests
Requires:	python3-PYjwt

%description
![Upload Python Package](https://github.com/cedarville-university/tdxlib/workflows/Upload%20Python%20Package/badge.svg)
# TDXLib (TeamDynamix Python SDK)

TDXLib is a suite of Python libraries originally designed to take input from Google Sheets and create tickets in [TeamDynamix](https://teamdynamix.com) based on the contents of the sheets. The scope of the project has broadened past its humble beginnings, and continues to do so whenever there's a feature we need that it doesn't currently support.

## Quick Links
* [ReadTheDocs.io Documentation](https://tdxlib.readthedocs.io) - TDXLib Class & Method descriptions
* [TeamDynamix API Documentation](https://api.teamdynamix.com/TDWebAPI) - Descriptions of all TDX API Endpoints

## Dependencies

### Required: 
* Python 3.6+
* requests
* python-dateutil
* pyjwt

## Quick-Start Guide

### Installation

1. [Download](https://www.python.org/) and install Python 3.6 or later. If you're new to Python, check out this [setup tutorial](https://realpython.com/installing-python/ "Python 3 Installation & Setup Guide"). For an introduction to basic Python syntax and use, check out the guides on [python.org](https://www.python.org/about/gettingstarted/) 

   _NOTE: although Python comes pre-installed on MacOS and many GNU/Linux systems, it's often version 2.7. For GNU/Linux, install python3 packages if available. For MacOS, check out [homebrew](brew.sh)._

2. **OPTION 1:** (Stable Release)
   
   Install via [pip](https://pypi.org) using the following command:
   
         pip install tdxlib
       
   This command will install any other required packages automatically.
   
   _Note: if you installed python3 packages, the Python v3 Pip may be called using ```pip3```_
   
   **OPTION 2:** (Latest Code)
   
   1. Clone or download TDXLib from [GitHub](https://github.com/cedarville-university/tdxlib).
   
      _NOTE: If you use Option 2, the root folder of the repository will need to be your scripts' working directory so you can import TDXLib without making changes to your ```PYTHONPATH``` variable_

   2. Install the required dependencies to your environment using `pip`, which is bundled with Python 3.4+. If you run into issues on Windows, be sure that the location of your Python installation is specified in your system's `PATH` variable.

      The necessary packages are specified in `requirements.txt` and can be installed with `pip` 
    
      If your OS comes with Python 2.7, use `pip3` or whatever the name of the Python 3.6+ pip binary is on your system. A [virtual environment](https://docs.python.org/3/library/venv.html) can be helpful here:

          pip install -r requirements.txt

      Alternatively, install all the packages manually:

          pip install requests python-dateutil
    
      To get the libraries necessary to work with Google Sheets (as in the [sample script](examples/example_ticket_generation.py)), you can also install them with `pip`:
        
          pip install gspread oauth2client

### Making a TDXlib integration object

4. Start a Python console:  
        
       python
       
5. Import TDXLib into your scripting environment:

       import tdxlib
    
6. To interact with the TDX API, you'll need to create an api integration object, through which all of the TDXLib commands are run. TDXLib currently supports two types of integrations:

   * **TDX Ticket Integration (Tickets, Ticket Tasks, etc.)**
   
         my_tdx_integration = tdxlib.tdx_ticket_integration.TDXTicketIntegration()

   * **TDX Asset Integration (Assets, CIs, etc.)**
         
         my_tdx_asset_integration = tdxlib.tdx_asset_integration.TDXAssetIntegration()

7. In order to store settings, TDXLib uses a INI-style configuration file. 
   If there is no file set up in your working directory, TDXLib will walk you through the generation of one the first time you instantiate an integration object:
  
      <pre>
        $ python
        Python 3.7.3 (...) [...] on [...]
        Type "help", "copyright", "credits" or "license" for more information.
        >>> <b>import tdxlib</b>
        >>> <b>tdx = tdxlib.tdx_ticket_integration.TDXTicketIntegration()</b>
        No configuration file found. Please enter the following information:
        
        Please enter your TeamDynamix organization name.
        This is the teamdynamix.com subdomain that you use to access TeamDynamix. 
        Alternatively, enter the fully qualified DNS name of your TDX instance:
        Organization Name/FQDN ({orgname}.teamdynamix.com/{orgname}.university.edu): <b>myuniversity</b>
        
        Use Sandbox? [Y/N]: <b>yes</b>
        
        TDX API Username (tdxuser@orgname.com): <b>myuser@myuniversity.edu</b>
        
        TDXLib can store the password for the API user in the configuration file.
        This is convenient, but not very secure.
        Store password for myuser@myuniversity.edu? [Y/N]: <b>no</b>
        
        Tickets App ID (optional): <b>123</b>
        
        Assets App ID (optional): <b>456</b>
        
        TDXLib uses (mostly) intelligent caching to speed up API calls on repetitive operations.
        In very dynamic environments, TDXLib's caching can cause issues.
        Disable Caching? [Y/N]: <b>no</b>
        
        Initial settings saved to: tdxlib.ini
       </pre>

    The generated file will look something like this:

        [TDX API Settings]
        'orgname': 'myuniversity',
        'fullhost': 'its.myuniversity.edu',
        'sandbox': True,
        'username': 'myuser@university.edu',
        'password': 'Prompt',
        'ticketAppId': '123',
        'assetAppId': '456',
        'caching': True,
        'log_level': 'ERROR'
     
    * The `orgname` field is whatever subdomain your organization uses to access TeamDynamix. For example, `https://myuniversity.teamdynamix.com`.

    * The `sandbox` field specifies whether TDXLib should interact with a sandbox version of the TDX Environment, which is written over by production monthly. It is recommended to use the sandbox environment when first getting familiar with the API environment.

    * The `username` and `password` fields are the login credentials for an account to be used with the TeamDynamix API. Many API endpoints (such as creating objects in TDX) require elevated permissions beyond the average user. You may need to create a user specifically for use with TDXLib and grant permissions based on what you need to do.
    
    * If the `password` field is set to `'Prompt'`, then whenever a new integration object is made, it will request a password, and dispose of the password after getting an API token: 
    
       <pre>Enter the TDX Password for user myuser@myuniversity.edu (this password will not be stored):   </pre>

    * The `ticketAppId` and `assetAppId` fields are the numbers that appear after `Apps` in your TeamDynamix URL, and are specific to your organization. You can find these ID's in the URLs in the following locations when using a TDX Tickets or Assets app through TDNext in your browser: 
    
      * Tickets: `https://myuniversity.teamdynamix.com/TDNext/Apps/{ticketAppId}/Tickets/...`  
      * Assets: `https://myuniversity.teamdynamix.com/TDNext/Apps/{assetAppId}/Assets/...`

    * The `caching` field specifies whether or not TDXLib should cache TeamDynamix objects such as valid ticket types, statuses and priorities. Setting this option to `True` reduces the volume of API calls and allows TDXLib to perform some batch operations much faster.

    * You can optionally specify an alternative configuration file that TDXLib should search for in your working directory. By default, it will look for `tdxlib.ini`.

          >>> tdx = tdx_ticket_integration.TDXTicketIntegration("specialconfig.ini")

    * Depending on your `tdxlib.ini` settings, you may be prompted for a password to authenticate into the TeamDynamix API. Once everything is working, go ahead and test out a method:

          >>> accounts = tdx.get_all_accounts()

9. Congratulations! You now have the power of the TeamDynamix API at your fingertips. For more detailed tutorials on how to use TDXLib to manipulate Tickets and Asset, as well as for information on the methods and classes included with TDXLib, check out our documentation on [ReadtheDocs.io](http://tdxlib.readthedocs.io).
    

##  TDXLib Implementation status and Future Plans

* ### TDXIntegration:

    This base class that contains the methods necessary to authenticate to Teamdynamix. This class also contains methods to interact with TeamDyanamix objects that are universal across various Apps (Locations, People, Accounts, etc.)

    Currently Implemented & Tested:
    * Authentication (only simple auth, no loginadmin or SSO)
    * Locations & Rooms (read-only)
    * People & Groups (read-only) (no group members)
    * Accounts (read-only)
    * Custom attributes for Tickets & Assets (read-only)
    * Import & Export of TDX-Style DateTime objects into python datetime objects
    * Read-write support for Accounts

    Future Plans:
    * Read-write support for Locations, Rooms, People, Groups, and Custom Attributes (in progress)
    * Support for custom attributes in Projects, CIs
    * Support for manipulating attachments
    * Support for inspecting/manipulating group members
    * Support for inspecting/manipulating roles & user lists
    * Support for mass-importing users from csv

    Unlikely to be supported:
    * Time entries
    * Time types

* ### TDXTicketIntegration:

    The class (inherited from TDXIntegration) that allows interactions with Ticket objects.

    #### Currently Implemented & Tested:
    * **Ticket Priorities**
    * **Ticket Statuses** (including creation of custom statuses) (WIP)
    * **Ticket Types**
    * **Ticket Urgencies**
    * **Ticket Sources**
    * **Ticket Impacts**
    * **Ticket Classifications** (not available directly through API)
    * **Ticket Forms** (not available directly through API)
    * **Tickets**
        * Creation (including templated batch-creation from Google Sheets)
        * Editing (including batch-editing of multiple )
        * Manipulating
            * Rescheduling
            * Reassigning
        * Searching (by any attribute)
        * Updating
        * Getting Feed Items
        * Uploading Attachments
    * **Ticket Tasks**
        * Creating
        * Editing
        * Deleting
        * Updating
        * Getting Feed Items

    #### Future Plans:
    * Tickets in combination with Assets
    
    #### Unlikely to be supported:
    * Blackout Windows
    * Ticket Searches/Reports

* ### TDXAssetIntegration:

    The class (inherited from TDXIntegration) that allows interactions with Asset objects.

    #### Currently Implemented & Tested:
    * **Assets**
        * Creating
        * Editing 
        * Searching
            * By Tag, SN, ID, Type, Owner, or any other attribute
        * Moving child assets fron one Asset to another
        * Copying attributes from one Asset to another
    * **Product Types**
        * Creating
        * Editing
        * Searching
    * **Product Models**
        * Creating
        * Editing
        * Searching
    * **Vendors**
        * Creating
        * Searching
    * **Asset Forms**
        * Searching
    * **Asset Statuses**
        * Searching
    
    #### Future Plans:
    * **Asset Statuses**
        * Creating
        * Editing
    * **Product Models**
        * Editing
    * **Vendors**
        * Editing
        * Deleting
    * **Accepting Suggestions...** (Submit an Issue!)


%package -n python3-TDXLib
Summary:	a python library for interacting with the TeamDynamix Web API
Provides:	python-TDXLib
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-TDXLib
![Upload Python Package](https://github.com/cedarville-university/tdxlib/workflows/Upload%20Python%20Package/badge.svg)
# TDXLib (TeamDynamix Python SDK)

TDXLib is a suite of Python libraries originally designed to take input from Google Sheets and create tickets in [TeamDynamix](https://teamdynamix.com) based on the contents of the sheets. The scope of the project has broadened past its humble beginnings, and continues to do so whenever there's a feature we need that it doesn't currently support.

## Quick Links
* [ReadTheDocs.io Documentation](https://tdxlib.readthedocs.io) - TDXLib Class & Method descriptions
* [TeamDynamix API Documentation](https://api.teamdynamix.com/TDWebAPI) - Descriptions of all TDX API Endpoints

## Dependencies

### Required: 
* Python 3.6+
* requests
* python-dateutil
* pyjwt

## Quick-Start Guide

### Installation

1. [Download](https://www.python.org/) and install Python 3.6 or later. If you're new to Python, check out this [setup tutorial](https://realpython.com/installing-python/ "Python 3 Installation & Setup Guide"). For an introduction to basic Python syntax and use, check out the guides on [python.org](https://www.python.org/about/gettingstarted/) 

   _NOTE: although Python comes pre-installed on MacOS and many GNU/Linux systems, it's often version 2.7. For GNU/Linux, install python3 packages if available. For MacOS, check out [homebrew](brew.sh)._

2. **OPTION 1:** (Stable Release)
   
   Install via [pip](https://pypi.org) using the following command:
   
         pip install tdxlib
       
   This command will install any other required packages automatically.
   
   _Note: if you installed python3 packages, the Python v3 Pip may be called using ```pip3```_
   
   **OPTION 2:** (Latest Code)
   
   1. Clone or download TDXLib from [GitHub](https://github.com/cedarville-university/tdxlib).
   
      _NOTE: If you use Option 2, the root folder of the repository will need to be your scripts' working directory so you can import TDXLib without making changes to your ```PYTHONPATH``` variable_

   2. Install the required dependencies to your environment using `pip`, which is bundled with Python 3.4+. If you run into issues on Windows, be sure that the location of your Python installation is specified in your system's `PATH` variable.

      The necessary packages are specified in `requirements.txt` and can be installed with `pip` 
    
      If your OS comes with Python 2.7, use `pip3` or whatever the name of the Python 3.6+ pip binary is on your system. A [virtual environment](https://docs.python.org/3/library/venv.html) can be helpful here:

          pip install -r requirements.txt

      Alternatively, install all the packages manually:

          pip install requests python-dateutil
    
      To get the libraries necessary to work with Google Sheets (as in the [sample script](examples/example_ticket_generation.py)), you can also install them with `pip`:
        
          pip install gspread oauth2client

### Making a TDXlib integration object

4. Start a Python console:  
        
       python
       
5. Import TDXLib into your scripting environment:

       import tdxlib
    
6. To interact with the TDX API, you'll need to create an api integration object, through which all of the TDXLib commands are run. TDXLib currently supports two types of integrations:

   * **TDX Ticket Integration (Tickets, Ticket Tasks, etc.)**
   
         my_tdx_integration = tdxlib.tdx_ticket_integration.TDXTicketIntegration()

   * **TDX Asset Integration (Assets, CIs, etc.)**
         
         my_tdx_asset_integration = tdxlib.tdx_asset_integration.TDXAssetIntegration()

7. In order to store settings, TDXLib uses a INI-style configuration file. 
   If there is no file set up in your working directory, TDXLib will walk you through the generation of one the first time you instantiate an integration object:
  
      <pre>
        $ python
        Python 3.7.3 (...) [...] on [...]
        Type "help", "copyright", "credits" or "license" for more information.
        >>> <b>import tdxlib</b>
        >>> <b>tdx = tdxlib.tdx_ticket_integration.TDXTicketIntegration()</b>
        No configuration file found. Please enter the following information:
        
        Please enter your TeamDynamix organization name.
        This is the teamdynamix.com subdomain that you use to access TeamDynamix. 
        Alternatively, enter the fully qualified DNS name of your TDX instance:
        Organization Name/FQDN ({orgname}.teamdynamix.com/{orgname}.university.edu): <b>myuniversity</b>
        
        Use Sandbox? [Y/N]: <b>yes</b>
        
        TDX API Username (tdxuser@orgname.com): <b>myuser@myuniversity.edu</b>
        
        TDXLib can store the password for the API user in the configuration file.
        This is convenient, but not very secure.
        Store password for myuser@myuniversity.edu? [Y/N]: <b>no</b>
        
        Tickets App ID (optional): <b>123</b>
        
        Assets App ID (optional): <b>456</b>
        
        TDXLib uses (mostly) intelligent caching to speed up API calls on repetitive operations.
        In very dynamic environments, TDXLib's caching can cause issues.
        Disable Caching? [Y/N]: <b>no</b>
        
        Initial settings saved to: tdxlib.ini
       </pre>

    The generated file will look something like this:

        [TDX API Settings]
        'orgname': 'myuniversity',
        'fullhost': 'its.myuniversity.edu',
        'sandbox': True,
        'username': 'myuser@university.edu',
        'password': 'Prompt',
        'ticketAppId': '123',
        'assetAppId': '456',
        'caching': True,
        'log_level': 'ERROR'
     
    * The `orgname` field is whatever subdomain your organization uses to access TeamDynamix. For example, `https://myuniversity.teamdynamix.com`.

    * The `sandbox` field specifies whether TDXLib should interact with a sandbox version of the TDX Environment, which is written over by production monthly. It is recommended to use the sandbox environment when first getting familiar with the API environment.

    * The `username` and `password` fields are the login credentials for an account to be used with the TeamDynamix API. Many API endpoints (such as creating objects in TDX) require elevated permissions beyond the average user. You may need to create a user specifically for use with TDXLib and grant permissions based on what you need to do.
    
    * If the `password` field is set to `'Prompt'`, then whenever a new integration object is made, it will request a password, and dispose of the password after getting an API token: 
    
       <pre>Enter the TDX Password for user myuser@myuniversity.edu (this password will not be stored):   </pre>

    * The `ticketAppId` and `assetAppId` fields are the numbers that appear after `Apps` in your TeamDynamix URL, and are specific to your organization. You can find these ID's in the URLs in the following locations when using a TDX Tickets or Assets app through TDNext in your browser: 
    
      * Tickets: `https://myuniversity.teamdynamix.com/TDNext/Apps/{ticketAppId}/Tickets/...`  
      * Assets: `https://myuniversity.teamdynamix.com/TDNext/Apps/{assetAppId}/Assets/...`

    * The `caching` field specifies whether or not TDXLib should cache TeamDynamix objects such as valid ticket types, statuses and priorities. Setting this option to `True` reduces the volume of API calls and allows TDXLib to perform some batch operations much faster.

    * You can optionally specify an alternative configuration file that TDXLib should search for in your working directory. By default, it will look for `tdxlib.ini`.

          >>> tdx = tdx_ticket_integration.TDXTicketIntegration("specialconfig.ini")

    * Depending on your `tdxlib.ini` settings, you may be prompted for a password to authenticate into the TeamDynamix API. Once everything is working, go ahead and test out a method:

          >>> accounts = tdx.get_all_accounts()

9. Congratulations! You now have the power of the TeamDynamix API at your fingertips. For more detailed tutorials on how to use TDXLib to manipulate Tickets and Asset, as well as for information on the methods and classes included with TDXLib, check out our documentation on [ReadtheDocs.io](http://tdxlib.readthedocs.io).
    

##  TDXLib Implementation status and Future Plans

* ### TDXIntegration:

    This base class that contains the methods necessary to authenticate to Teamdynamix. This class also contains methods to interact with TeamDyanamix objects that are universal across various Apps (Locations, People, Accounts, etc.)

    Currently Implemented & Tested:
    * Authentication (only simple auth, no loginadmin or SSO)
    * Locations & Rooms (read-only)
    * People & Groups (read-only) (no group members)
    * Accounts (read-only)
    * Custom attributes for Tickets & Assets (read-only)
    * Import & Export of TDX-Style DateTime objects into python datetime objects
    * Read-write support for Accounts

    Future Plans:
    * Read-write support for Locations, Rooms, People, Groups, and Custom Attributes (in progress)
    * Support for custom attributes in Projects, CIs
    * Support for manipulating attachments
    * Support for inspecting/manipulating group members
    * Support for inspecting/manipulating roles & user lists
    * Support for mass-importing users from csv

    Unlikely to be supported:
    * Time entries
    * Time types

* ### TDXTicketIntegration:

    The class (inherited from TDXIntegration) that allows interactions with Ticket objects.

    #### Currently Implemented & Tested:
    * **Ticket Priorities**
    * **Ticket Statuses** (including creation of custom statuses) (WIP)
    * **Ticket Types**
    * **Ticket Urgencies**
    * **Ticket Sources**
    * **Ticket Impacts**
    * **Ticket Classifications** (not available directly through API)
    * **Ticket Forms** (not available directly through API)
    * **Tickets**
        * Creation (including templated batch-creation from Google Sheets)
        * Editing (including batch-editing of multiple )
        * Manipulating
            * Rescheduling
            * Reassigning
        * Searching (by any attribute)
        * Updating
        * Getting Feed Items
        * Uploading Attachments
    * **Ticket Tasks**
        * Creating
        * Editing
        * Deleting
        * Updating
        * Getting Feed Items

    #### Future Plans:
    * Tickets in combination with Assets
    
    #### Unlikely to be supported:
    * Blackout Windows
    * Ticket Searches/Reports

* ### TDXAssetIntegration:

    The class (inherited from TDXIntegration) that allows interactions with Asset objects.

    #### Currently Implemented & Tested:
    * **Assets**
        * Creating
        * Editing 
        * Searching
            * By Tag, SN, ID, Type, Owner, or any other attribute
        * Moving child assets fron one Asset to another
        * Copying attributes from one Asset to another
    * **Product Types**
        * Creating
        * Editing
        * Searching
    * **Product Models**
        * Creating
        * Editing
        * Searching
    * **Vendors**
        * Creating
        * Searching
    * **Asset Forms**
        * Searching
    * **Asset Statuses**
        * Searching
    
    #### Future Plans:
    * **Asset Statuses**
        * Creating
        * Editing
    * **Product Models**
        * Editing
    * **Vendors**
        * Editing
        * Deleting
    * **Accepting Suggestions...** (Submit an Issue!)


%package help
Summary:	Development documents and examples for TDXLib
Provides:	python3-TDXLib-doc
%description help
![Upload Python Package](https://github.com/cedarville-university/tdxlib/workflows/Upload%20Python%20Package/badge.svg)
# TDXLib (TeamDynamix Python SDK)

TDXLib is a suite of Python libraries originally designed to take input from Google Sheets and create tickets in [TeamDynamix](https://teamdynamix.com) based on the contents of the sheets. The scope of the project has broadened past its humble beginnings, and continues to do so whenever there's a feature we need that it doesn't currently support.

## Quick Links
* [ReadTheDocs.io Documentation](https://tdxlib.readthedocs.io) - TDXLib Class & Method descriptions
* [TeamDynamix API Documentation](https://api.teamdynamix.com/TDWebAPI) - Descriptions of all TDX API Endpoints

## Dependencies

### Required: 
* Python 3.6+
* requests
* python-dateutil
* pyjwt

## Quick-Start Guide

### Installation

1. [Download](https://www.python.org/) and install Python 3.6 or later. If you're new to Python, check out this [setup tutorial](https://realpython.com/installing-python/ "Python 3 Installation & Setup Guide"). For an introduction to basic Python syntax and use, check out the guides on [python.org](https://www.python.org/about/gettingstarted/) 

   _NOTE: although Python comes pre-installed on MacOS and many GNU/Linux systems, it's often version 2.7. For GNU/Linux, install python3 packages if available. For MacOS, check out [homebrew](brew.sh)._

2. **OPTION 1:** (Stable Release)
   
   Install via [pip](https://pypi.org) using the following command:
   
         pip install tdxlib
       
   This command will install any other required packages automatically.
   
   _Note: if you installed python3 packages, the Python v3 Pip may be called using ```pip3```_
   
   **OPTION 2:** (Latest Code)
   
   1. Clone or download TDXLib from [GitHub](https://github.com/cedarville-university/tdxlib).
   
      _NOTE: If you use Option 2, the root folder of the repository will need to be your scripts' working directory so you can import TDXLib without making changes to your ```PYTHONPATH``` variable_

   2. Install the required dependencies to your environment using `pip`, which is bundled with Python 3.4+. If you run into issues on Windows, be sure that the location of your Python installation is specified in your system's `PATH` variable.

      The necessary packages are specified in `requirements.txt` and can be installed with `pip` 
    
      If your OS comes with Python 2.7, use `pip3` or whatever the name of the Python 3.6+ pip binary is on your system. A [virtual environment](https://docs.python.org/3/library/venv.html) can be helpful here:

          pip install -r requirements.txt

      Alternatively, install all the packages manually:

          pip install requests python-dateutil
    
      To get the libraries necessary to work with Google Sheets (as in the [sample script](examples/example_ticket_generation.py)), you can also install them with `pip`:
        
          pip install gspread oauth2client

### Making a TDXlib integration object

4. Start a Python console:  
        
       python
       
5. Import TDXLib into your scripting environment:

       import tdxlib
    
6. To interact with the TDX API, you'll need to create an api integration object, through which all of the TDXLib commands are run. TDXLib currently supports two types of integrations:

   * **TDX Ticket Integration (Tickets, Ticket Tasks, etc.)**
   
         my_tdx_integration = tdxlib.tdx_ticket_integration.TDXTicketIntegration()

   * **TDX Asset Integration (Assets, CIs, etc.)**
         
         my_tdx_asset_integration = tdxlib.tdx_asset_integration.TDXAssetIntegration()

7. In order to store settings, TDXLib uses a INI-style configuration file. 
   If there is no file set up in your working directory, TDXLib will walk you through the generation of one the first time you instantiate an integration object:
  
      <pre>
        $ python
        Python 3.7.3 (...) [...] on [...]
        Type "help", "copyright", "credits" or "license" for more information.
        >>> <b>import tdxlib</b>
        >>> <b>tdx = tdxlib.tdx_ticket_integration.TDXTicketIntegration()</b>
        No configuration file found. Please enter the following information:
        
        Please enter your TeamDynamix organization name.
        This is the teamdynamix.com subdomain that you use to access TeamDynamix. 
        Alternatively, enter the fully qualified DNS name of your TDX instance:
        Organization Name/FQDN ({orgname}.teamdynamix.com/{orgname}.university.edu): <b>myuniversity</b>
        
        Use Sandbox? [Y/N]: <b>yes</b>
        
        TDX API Username (tdxuser@orgname.com): <b>myuser@myuniversity.edu</b>
        
        TDXLib can store the password for the API user in the configuration file.
        This is convenient, but not very secure.
        Store password for myuser@myuniversity.edu? [Y/N]: <b>no</b>
        
        Tickets App ID (optional): <b>123</b>
        
        Assets App ID (optional): <b>456</b>
        
        TDXLib uses (mostly) intelligent caching to speed up API calls on repetitive operations.
        In very dynamic environments, TDXLib's caching can cause issues.
        Disable Caching? [Y/N]: <b>no</b>
        
        Initial settings saved to: tdxlib.ini
       </pre>

    The generated file will look something like this:

        [TDX API Settings]
        'orgname': 'myuniversity',
        'fullhost': 'its.myuniversity.edu',
        'sandbox': True,
        'username': 'myuser@university.edu',
        'password': 'Prompt',
        'ticketAppId': '123',
        'assetAppId': '456',
        'caching': True,
        'log_level': 'ERROR'
     
    * The `orgname` field is whatever subdomain your organization uses to access TeamDynamix. For example, `https://myuniversity.teamdynamix.com`.

    * The `sandbox` field specifies whether TDXLib should interact with a sandbox version of the TDX Environment, which is written over by production monthly. It is recommended to use the sandbox environment when first getting familiar with the API environment.

    * The `username` and `password` fields are the login credentials for an account to be used with the TeamDynamix API. Many API endpoints (such as creating objects in TDX) require elevated permissions beyond the average user. You may need to create a user specifically for use with TDXLib and grant permissions based on what you need to do.
    
    * If the `password` field is set to `'Prompt'`, then whenever a new integration object is made, it will request a password, and dispose of the password after getting an API token: 
    
       <pre>Enter the TDX Password for user myuser@myuniversity.edu (this password will not be stored):   </pre>

    * The `ticketAppId` and `assetAppId` fields are the numbers that appear after `Apps` in your TeamDynamix URL, and are specific to your organization. You can find these ID's in the URLs in the following locations when using a TDX Tickets or Assets app through TDNext in your browser: 
    
      * Tickets: `https://myuniversity.teamdynamix.com/TDNext/Apps/{ticketAppId}/Tickets/...`  
      * Assets: `https://myuniversity.teamdynamix.com/TDNext/Apps/{assetAppId}/Assets/...`

    * The `caching` field specifies whether or not TDXLib should cache TeamDynamix objects such as valid ticket types, statuses and priorities. Setting this option to `True` reduces the volume of API calls and allows TDXLib to perform some batch operations much faster.

    * You can optionally specify an alternative configuration file that TDXLib should search for in your working directory. By default, it will look for `tdxlib.ini`.

          >>> tdx = tdx_ticket_integration.TDXTicketIntegration("specialconfig.ini")

    * Depending on your `tdxlib.ini` settings, you may be prompted for a password to authenticate into the TeamDynamix API. Once everything is working, go ahead and test out a method:

          >>> accounts = tdx.get_all_accounts()

9. Congratulations! You now have the power of the TeamDynamix API at your fingertips. For more detailed tutorials on how to use TDXLib to manipulate Tickets and Asset, as well as for information on the methods and classes included with TDXLib, check out our documentation on [ReadtheDocs.io](http://tdxlib.readthedocs.io).
    

##  TDXLib Implementation status and Future Plans

* ### TDXIntegration:

    This base class that contains the methods necessary to authenticate to Teamdynamix. This class also contains methods to interact with TeamDyanamix objects that are universal across various Apps (Locations, People, Accounts, etc.)

    Currently Implemented & Tested:
    * Authentication (only simple auth, no loginadmin or SSO)
    * Locations & Rooms (read-only)
    * People & Groups (read-only) (no group members)
    * Accounts (read-only)
    * Custom attributes for Tickets & Assets (read-only)
    * Import & Export of TDX-Style DateTime objects into python datetime objects
    * Read-write support for Accounts

    Future Plans:
    * Read-write support for Locations, Rooms, People, Groups, and Custom Attributes (in progress)
    * Support for custom attributes in Projects, CIs
    * Support for manipulating attachments
    * Support for inspecting/manipulating group members
    * Support for inspecting/manipulating roles & user lists
    * Support for mass-importing users from csv

    Unlikely to be supported:
    * Time entries
    * Time types

* ### TDXTicketIntegration:

    The class (inherited from TDXIntegration) that allows interactions with Ticket objects.

    #### Currently Implemented & Tested:
    * **Ticket Priorities**
    * **Ticket Statuses** (including creation of custom statuses) (WIP)
    * **Ticket Types**
    * **Ticket Urgencies**
    * **Ticket Sources**
    * **Ticket Impacts**
    * **Ticket Classifications** (not available directly through API)
    * **Ticket Forms** (not available directly through API)
    * **Tickets**
        * Creation (including templated batch-creation from Google Sheets)
        * Editing (including batch-editing of multiple )
        * Manipulating
            * Rescheduling
            * Reassigning
        * Searching (by any attribute)
        * Updating
        * Getting Feed Items
        * Uploading Attachments
    * **Ticket Tasks**
        * Creating
        * Editing
        * Deleting
        * Updating
        * Getting Feed Items

    #### Future Plans:
    * Tickets in combination with Assets
    
    #### Unlikely to be supported:
    * Blackout Windows
    * Ticket Searches/Reports

* ### TDXAssetIntegration:

    The class (inherited from TDXIntegration) that allows interactions with Asset objects.

    #### Currently Implemented & Tested:
    * **Assets**
        * Creating
        * Editing 
        * Searching
            * By Tag, SN, ID, Type, Owner, or any other attribute
        * Moving child assets fron one Asset to another
        * Copying attributes from one Asset to another
    * **Product Types**
        * Creating
        * Editing
        * Searching
    * **Product Models**
        * Creating
        * Editing
        * Searching
    * **Vendors**
        * Creating
        * Searching
    * **Asset Forms**
        * Searching
    * **Asset Statuses**
        * Searching
    
    #### Future Plans:
    * **Asset Statuses**
        * Creating
        * Editing
    * **Product Models**
        * Editing
    * **Vendors**
        * Editing
        * Deleting
    * **Accepting Suggestions...** (Submit an Issue!)


%prep
%autosetup -n TDXLib-0.4.3

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-TDXLib -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.3-1
- Package Spec generated