IBM Security QRadar SOAR

 View Only
  • 1.  Get the list of values for a Select Field

    Posted Thu May 28, 2020 08:01 AM
    Hi,
    I need to patch a "Select" field with the appropriate values.

    Using the resilient python library, how do I get the list of values(LOV) so I see the text/values, and then apply the values to the field.

    Most grateful for any help.

    ------------------------------
    Apronti Gilbert
    ------------------------------


  • 2.  RE: Get the list of values for a Select Field

    Posted Fri May 29, 2020 08:26 AM
    Not sure about the python library but this information may help.

    The API you can use is

    GET /orgs/{org_id}/types/{type}/fields/{field}​



    For example
    /orgs/202/types/incident/fields/phase_id​




    returns this. Notice that the list of possible values is returned.

    Ben


    {
      "id": 81,
      "name": "phase_id",
      "text": "Phase",
      "prefix": null,
      "type_id": 0,
      "tooltip": "The phase of the incident.",
      "placeholder": "",
      "input_type": "select",
      "hide_notification": false,
      "chosen": false,
      "default_chosen_by_server": false,
      "blank_option": false,
      "internal": true,
      "uuid": "ea47a365-620d-4419-a767-f1b08f2685d7",
      "operations": [
        "equals",
        "not_equals",
        "in",
        "not_in",
        "changed",
        "changed_to",
        "not_changed_to",
        "has_a_value",
        "not_has_a_value"
      ],
      "operation_perms": {
        "not_changed_to": {
          "show_in_manual_actions": false,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "equals": {
          "show_in_manual_actions": true,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "not_has_a_value": {
          "show_in_manual_actions": true,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "not_equals": {
          "show_in_manual_actions": true,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "has_a_value": {
          "show_in_manual_actions": true,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "changed": {
          "show_in_manual_actions": false,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "in": {
          "show_in_manual_actions": true,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "not_in": {
          "show_in_manual_actions": true,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        },
        "changed_to": {
          "show_in_manual_actions": false,
          "show_in_auto_actions": true,
          "show_in_notifications": true
        }
      },
      "values": [
        {
          "value": 1013,
          "label": "Initial",
          "enabled": true,
          "properties": null,
          "uuid": "5558dfa9-3c70-498b-aa39-c1538c1ae671",
          "hidden": false,
          "default": false
        },
        {
          "value": 2007,
          "label": "All objs phase",
          "enabled": true,
          "properties": null,
          "uuid": "158b0469-5493-4fc3-a0a0-2651dc5e88dd",
          "hidden": false,
          "default": false
        },
        {
          "value": 1092,
          "label": "Phase 1",
          "enabled": false,
          "properties": null,
          "uuid": "9b4442f7-5bfa-41bb-8607-5c668ecdf7d1",
          "hidden": false,
          "default": false
        },
        {
          "value": 1010,
          "label": "Engage",
          "enabled": true,
          "properties": null,
          "uuid": "ed053e3a-2d6d-47e1-8240-844ed93d4893",
          "hidden": false,
          "default": false
        },
        {
          "value": 1012,
          "label": "Detect/Analyze",
          "enabled": false,
          "properties": null,
          "uuid": "44868c86-246e-4e6e-8636-fa2848b2f279",
          "hidden": false,
          "default": false
        },
        {
          "value": 1057,
          "label": "Decision: Escalate or Mobilize",
          "enabled": true,
          "properties": null,
          "uuid": "1896963a-689d-496c-af60-87e47e53a133",
          "hidden": false,
          "default": false
        },
        {
          "value": 2008,
          "label": "Denise Phase",
          "enabled": true,
          "properties": null,
          "uuid": "7f3e9ed6-2ea4-4b6f-85ac-7bfff4390fe2",
          "hidden": false,
          "default": false
        },
        {
          "value": 1227,
          "label": "Respond2",
          "enabled": false,
          "properties": null,
          "uuid": "ebad851d-5b5e-4d19-af79-fae53cc1f659",
          "hidden": false,
          "default": false
        },
        {
          "value": 1043,
          "label": "Release Candidate 2 Testing",
          "enabled": false,
          "properties": null,
          "uuid": "01c35a65-b877-41dd-ad3c-2bd55413d23f",
          "hidden": false,
          "default": false
        },
        {
          "value": 1212,
          "label": "Identify (Help Desk, Monitoring)",
          "enabled": true,
          "properties": null,
          "uuid": "ffd06b69-1f9c-48f5-a352-d2159f8478fd",
          "hidden": false,
          "default": false
        },
        {
          "value": 1008,
          "label": "Post-Incident",
          "enabled": true,
          "properties": null,
          "uuid": "280a7bbe-3d93-4191-973f-2723b282a7e0",
          "hidden": false,
          "default": false
        },
        {
          "value": 1011,
          "label": "Custom",
          "enabled": true,
          "properties": null,
          "uuid": "247d4b79-1762-4d70-bb95-67d83b104eff",
          "hidden": false,
          "default": false
        },
        {
          "value": 1094,
          "label": "Phase 2",
          "enabled": true,
          "properties": null,
          "uuid": "6af1d0e0-f8e6-4c03-b966-1fd4da6c76c9",
          "hidden": false,
          "default": false
        },
        {
          "value": 1215,
          "label": "Identify (Monitoring, Validation)",
          "enabled": true,
          "properties": null,
          "uuid": "559989d8-ddcf-4e16-80fb-4ec3c11b8a3a",
          "hidden": false,
          "default": false
        },
        {
          "value": 1095,
          "label": "Phase 3",
          "enabled": true,
          "properties": null,
          "uuid": "3931b6fa-51c7-4492-98e3-52ce97c7e0c5",
          "hidden": false,
          "default": false
        },
        {
          "value": 1216,
          "label": "Analysis_NIST-02b",
          "enabled": true,
          "properties": null,
          "uuid": "3a10d909-f0f5-4d4e-bc2a-05eb4a18cbf6",
          "hidden": false,
          "default": false
        },
        {
          "value": 1217,
          "label": "Containment_NIST-03a",
          "enabled": true,
          "properties": null,
          "uuid": "8e25d8f3-f918-40ff-8efc-f3f6a1439126",
          "hidden": false,
          "default": false
        },
        {
          "value": 1218,
          "label": "Remediate (Containment)",
          "enabled": true,
          "properties": null,
          "uuid": "c115b237-2185-434a-8024-10e4089dccb9",
          "hidden": false,
          "default": false
        },
        {
          "value": 1214,
          "label": "Detection_NIST-02a",
          "enabled": true,
          "properties": null,
          "uuid": "aaa8960b-9f21-476a-84f1-250c44268b63",
          "hidden": false,
          "default": false
        },
        {
          "value": 1219,
          "label": "Eradication-and-Recovery_NIST-03b",
          "enabled": true,
          "properties": null,
          "uuid": "d982879f-9622-48f4-b708-c22dde77a89e",
          "hidden": false,
          "default": false
        },
        {
          "value": 1058,
          "label": "IR-Remediation",
          "enabled": true,
          "properties": null,
          "uuid": "9edfe21d-ce80-441c-a3f4-1475fbc8c5e2",
          "hidden": false,
          "default": false
        },
        {
          "value": 1220,
          "label": "Remediate (Eradication)",
          "enabled": true,
          "properties": null,
          "uuid": "acb2bedb-182f-4d2b-b81f-9c40d82643e5",
          "hidden": false,
          "default": false
        },
        {
          "value": 1221,
          "label": "Post-Incident-Activity_NIST-04",
          "enabled": true,
          "properties": null,
          "uuid": "adcb0824-8f48-4e2c-b4fd-d2fc9cf42987",
          "hidden": false,
          "default": false
        },
        {
          "value": 1093,
          "label": "Sub-phase",
          "enabled": true,
          "properties": null,
          "uuid": "7279593c-fc2a-4901-9b0e-91261b89f074",
          "hidden": false,
          "default": false
        },
        {
          "value": 1059,
          "label": "Recover",
          "enabled": true,
          "properties": null,
          "uuid": "5d016b2f-81dc-4892-99c8-c419588443d8",
          "hidden": false,
          "default": false
        },
        {
          "value": 1042,
          "label": "Regression",
          "enabled": true,
          "properties": null,
          "uuid": "a24ad385-e95d-4041-b11c-69d4ad7148e1",
          "hidden": false,
          "default": false
        },
        {
          "value": 1230,
          "label": "This is a new empty phase",
          "enabled": true,
          "properties": null,
          "uuid": "34536b42-e42d-4624-92c7-910e6aa21b5b",
          "hidden": false,
          "default": false
        },
        {
          "value": 1222,
          "label": "Remediate (Recover)",
          "enabled": true,
          "properties": null,
          "uuid": "ff2e51ec-3279-4925-90ab-b8953479e618",
          "hidden": false,
          "default": false
        },
        {
          "value": 1223,
          "label": "Adapt (Report)",
          "enabled": true,
          "properties": null,
          "uuid": "38b1da9f-e6db-4775-bd1f-9ce63dcd05c4",
          "hidden": false,
          "default": false
        },
        {
          "value": 1224,
          "label": "Adapt (Closure)",
          "enabled": true,
          "properties": null,
          "uuid": "a95c7d3b-07cd-4b92-9e0f-02c593a2d4ca",
          "hidden": false,
          "default": false
        },
        {
          "value": 1225,
          "label": "Another Name",
          "enabled": true,
          "properties": null,
          "uuid": "572a093b-abbb-42b7-a560-47284f70edef",
          "hidden": false,
          "default": false
        },
        {
          "value": 1060,
          "label": "Discovery",
          "enabled": true,
          "properties": null,
          "uuid": "c51f7d85-7a28-4834-b9b2-2227ab280e3e",
          "hidden": false,
          "default": false
        },
        {
          "value": 1226,
          "label": "Error damn you",
          "enabled": true,
          "properties": null,
          "uuid": "a60e8f96-236a-4bd2-ac48-4eb61ad04218",
          "hidden": false,
          "default": false
        },
        {
          "value": 1044,
          "label": "Upgrades",
          "enabled": true,
          "properties": null,
          "uuid": "411f66a1-fd70-4299-8d46-0d88776b4b0c",
          "hidden": false,
          "default": false
        },
        {
          "value": 1110,
          "label": "gfg",
          "enabled": false,
          "properties": null,
          "uuid": "04afeabc-7626-4a02-92ba-af58966359b7",
          "hidden": false,
          "default": false
        },
        {
          "value": 1045,
          "label": "Interoperability",
          "enabled": true,
          "properties": null,
          "uuid": "d90aebb1-29ff-41ed-b3ae-48a2d62eff5f",
          "hidden": false,
          "default": false
        },
        {
          "value": 1111,
          "label": "ben",
          "enabled": false,
          "properties": null,
          "uuid": "ead2413e-065b-43c1-87c6-e29f7b59f9a8",
          "hidden": false,
          "default": false
        },
        {
          "value": 1061,
          "label": "MSTIC - Alert",
          "enabled": true,
          "properties": null,
          "uuid": "0156a05f-1f41-480d-9587-403ef632db15",
          "hidden": false,
          "default": false
        },
        {
          "value": 1213,
          "label": "Preparation_NIST-01",
          "enabled": true,
          "properties": null,
          "uuid": "ca6b1efb-f0fa-4093-b7af-0a5f2d4b80d1",
          "hidden": false,
          "default": false
        },
        {
          "value": 1062,
          "label": "MSTIC - Triage",
          "enabled": true,
          "properties": null,
          "uuid": "00c08dc4-bbb6-424c-8678-1423f7a9f64f",
          "hidden": false,
          "default": false
        },
        {
          "value": 1063,
          "label": "MSTIC - Mobilization",
          "enabled": true,
          "properties": null,
          "uuid": "d8470acf-3fff-47b0-bc4c-55daf2cc519a",
          "hidden": false,
          "default": false
        },
        {
          "value": 1064,
          "label": "MSTIC - Assess & Analyze",
          "enabled": true,
          "properties": null,
          "uuid": "f9c5b087-dd74-4104-a172-df3c55aefd30",
          "hidden": false,
          "default": false
        },
        {
          "value": 1046,
          "label": "Pre-Release",
          "enabled": true,
          "properties": null,
          "uuid": "757e325f-ed97-4610-981f-2a2681bfe21e",
          "hidden": false,
          "default": false
        },
        {
          "value": 1065,
          "label": "MSTIC - Stabilize",
          "enabled": true,
          "properties": null,
          "uuid": "46c210a1-6c32-4055-b038-9cebf52b3cec",
          "hidden": false,
          "default": false
        },
        {
          "value": 1066,
          "label": "MSTIC - Remediate & Resolve",
          "enabled": true,
          "properties": null,
          "uuid": "34f01bfc-9c40-487f-9663-9b66257cd647",
          "hidden": false,
          "default": false
        },
        {
          "value": 1067,
          "label": "MSTIC - Post Incident Monitor",
          "enabled": true,
          "properties": null,
          "uuid": "4c6c3596-f331-42f9-838a-2cbe180b093d",
          "hidden": false,
          "default": false
        },
        {
          "value": 1068,
          "label": "Post Incident Activity",
          "enabled": true,
          "properties": null,
          "uuid": "552eedcd-3c99-4420-af06-1e6cdd48c3c9",
          "hidden": false,
          "default": false
        },
        {
          "value": 1432,
          "label": "Temp Demo",
          "enabled": true,
          "properties": null,
          "uuid": "66425fda-10c5-4ed6-a77f-c37b71e77e38",
          "hidden": false,
          "default": false
        },
        {
          "value": 1637,
          "label": "bleh",
          "enabled": true,
          "properties": null,
          "uuid": "277e7652-2c6f-4e12-a137-6ac393ab6493",
          "hidden": false,
          "default": false
        },
        {
          "value": 1047,
          "label": "Release Checklist",
          "enabled": true,
          "properties": null,
          "uuid": "81626f0a-3cef-4c9c-ab48-6d0189f65403",
          "hidden": false,
          "default": false
        },
        {
          "value": 1211,
          "label": "Bob Phase",
          "enabled": true,
          "properties": null,
          "uuid": "1ae09b78-a24d-40b2-b0e7-68f233ee34bd",
          "hidden": false,
          "default": false
        },
        {
          "value": 1048,
          "label": "V24 - New Features",
          "enabled": true,
          "properties": null,
          "uuid": "6d9ffed5-4ed6-4609-b868-07d66a390fca",
          "hidden": false,
          "default": false
        },
        {
          "value": 1132,
          "label": "Jurisdiction",
          "enabled": true,
          "properties": null,
          "uuid": "86f6c245-d758-4166-8c2c-366d1acbc8ce",
          "hidden": false,
          "default": false
        },
        {
          "value": 1148,
          "label": "Before Completion",
          "enabled": true,
          "properties": null,
          "uuid": "d767a780-6f2a-44ce-97ff-5c6b985d71a8",
          "hidden": false,
          "default": false
        },
        {
          "value": 1171,
          "label": "new_phase",
          "enabled": true,
          "properties": null,
          "uuid": "411b1d87-b9b0-4225-a46a-b24e5edd9a95",
          "hidden": false,
          "default": false
        },
        {
          "value": 1641,
          "label": "Mikes Youthful Phase",
          "enabled": true,
          "properties": null,
          "uuid": "cf2cf768-2ac2-4420-b05d-923c5626e4ac",
          "hidden": false,
          "default": false
        },
        {
          "value": 1186,
          "label": "Test",
          "enabled": false,
          "properties": null,
          "uuid": "95899f0f-e8f0-4ec8-ad90-3c1f4cce56d4",
          "hidden": false,
          "default": false
        },
        {
          "value": 1466,
          "label": "DE2698",
          "enabled": false,
          "properties": null,
          "uuid": "86e17968-63c1-4c65-993a-9847c9bb4030",
          "hidden": false,
          "default": false
        },
        {
          "value": 1007,
          "label": "Respond-Old",
          "enabled": true,
          "properties": null,
          "uuid": "31bf6cb4-5858-4986-9bd3-7a1e797e20b7",
          "hidden": false,
          "default": false
        },
        {
          "value": 1293,
          "label": "POOOOOO",
          "enabled": false,
          "properties": null,
          "uuid": "2aab082f-e696-47fd-a610-4c5fb717e633",
          "hidden": false,
          "default": false
        },
        {
          "value": 1652,
          "label": "Test Phae",
          "enabled": true,
          "properties": null,
          "uuid": "1ac138cc-c12e-4676-b33a-2b7bb1e4814d",
          "hidden": false,
          "default": false
        },
        {
          "value": 1681,
          "label": "Inital Check",
          "enabled": true,
          "properties": null,
          "uuid": "97356c5c-9626-4b56-865d-f546d11301c0",
          "hidden": false,
          "default": false
        },
        {
          "value": 1689,
          "label": "!st Phase - Do the check",
          "enabled": true,
          "properties": null,
          "uuid": "f906e8be-5cf0-40e0-bf38-c0c0c0f2d2a6",
          "hidden": false,
          "default": false
        },
        {
          "value": 1720,
          "label": "CSAT YELLOW",
          "enabled": true,
          "properties": null,
          "uuid": "67df91cf-a0d0-43e0-ac65-8818fad98be8",
          "hidden": false,
          "default": false
        },
        {
          "value": 2016,
          "label": "MikesPhase",
          "enabled": true,
          "properties": null,
          "uuid": "b9086282-d8c9-4821-b295-0f4a943eb437",
          "hidden": false,
          "default": false
        },
        {
          "value": 2759,
          "label": "SimonDeleteMe",
          "enabled": true,
          "properties": null,
          "uuid": "a9fe1a69-dac6-4cd1-a30f-90936cbf0703",
          "hidden": false,
          "default": false
        },
        {
          "value": 2768,
          "label": "testphase1",
          "enabled": true,
          "properties": null,
          "uuid": "a31cb6e2-45c8-4023-aa54-bdaaa3da7cd3",
          "hidden": false,
          "default": false
        },
        {
          "value": 1009,
          "label": "Complete",
          "enabled": true,
          "properties": null,
          "uuid": "d057ec97-587e-44c0-ae84-c4fadd6d7e40",
          "hidden": false,
          "default": false
        }
      ],
      "perms": {
        "delete": false,
        "modify_name": false,
        "modify_values": false,
        "modify_blank": false,
        "modify_required": false,
        "modify_operations": false,
        "modify_chosen": false,
        "modify_default": false,
        "show_in_manual_actions": true,
        "show_in_auto_actions": true,
        "show_in_notifications": true,
        "show_in_scripts": true,
        "modify_type": [
          "select"
        ],
        "sort": true
      },
      "read_only": true,
      "changeable": true,
      "rich_text": false,
      "templates": [],
      "deprecated": false,
      "tags": [],
      "calculated": false,
      "is_tracked": true,
      "allow_default_value": false
    }



    ------------------------------
    Ben Lurie
    ------------------------------



  • 3.  RE: Get the list of values for a Select Field
    Best Answer

    Posted Fri May 29, 2020 08:53 AM
    Hi Apronti

    I have recently written code that let's the user overrides default values of a select field with this code:
        def init_close_codes(self, close_codes):
            """
            init_close_codes takes a list of string close-codes for Secureworks CTP and places them in the
            select (swcx_ctp_close_code custom incident field) input type.  There are default codes defined in
            the Resilient UI but users can override the select list via app.config 'close_codes' parameter.
            The close codes are similar to Resilient resolution_id. The select list will appear in the
            Resilient Close Incident popup when the user closes an incident.
            :param close_codes: list of strings (each string will be an entry in the select list) which will appear
            in the Resilient Close Incident popup
            :return: response from the 'put' operation
            """
            # Get the current close_code select list.
            uri = '/types/incident/fields/scwx_ctp_close_code'
            get_response = self.rest_client().get(uri)
            values = []
    
            # Add each close_code as a select list entry.
            for code in close_codes:
                entry = {'label': code,
                         'enabled': True,
                         'hidden': False}
                values.append(entry)
    
            # Put the new values into the select list to replace the currently values there.
            get_response['values'] = values
            put_response = self.rest_client().put(uri, payload=get_response)
    
            return put_response
    ​
    Hope this helps?


    ------------------------------
    AnnMarie Norcross
    ------------------------------



  • 4.  RE: Get the list of values for a Select Field

    Posted Mon June 01, 2020 05:32 AM
    Thanks @Ben Lurie and @AnnMarie Norcross,
    Your input and guide was really helpful.
    ​​I was able to get the values with code below;
    from dotenv import load_dotenv
    import os
    import resilient
    load_dotenv()resilient_cfg={
        "host": os.getenv("resilient_host"),
        "port": os.getenv("resilient_port"),
        "api_key_id": os.getenv("resilient_api_key_id"),
        "api_key_secret": os.getenv("resilient_api_key_secret"),
        "org": os.getenv("resilient_org"),
        "cafile": os.getenv("resilient_cafile")
    }
    client = resilient.get_client(resilient_cfg)# /types/incident/fields/{field_name}uri = '/types/incident/fields/c_case_source'
    get_response = client.get(uri)["values"]
    print(get_response)

    ------------------------------
    Apronti Gilbert
    ------------------------------



  • 5.  RE: Get the list of values for a Select Field

    Posted Tue June 09, 2020 12:13 PM
    Hello, Apronti - I have a rather crude little standalone utility for field value display and update that works for Select and Multiselect fields.  It only operates on one value at a time and allows individual label updates on currently selectable (valid) values of the named field.

    First the program opens a client to the configured Resilient instance:
    import resilient
    from resilient.co3argparse import ArgumentParser
    import FieldInquiries
    import Utilities
    import time

    parser = ArgumentParser(config_file="app.config")
    opts = parser.parse_args()

    client = resilient.co3.get_client(opts)


    Then here is the relevant code:

    def amendSelectedField(self, client, select_field_name, fromValue, toValue, is_property=True, cleanup_permitted=False):
    global deprecated_values
    global valid_values

    fieldDescription = "Unknown"

    if is_property:
    fieldDescription = "a Resilient property"
    else:
    fieldDescription = "an intrinsic Resilient field (NOT a Property)"

    if not fromValue:
    if toValue:
    print ("You have provided the 'target' value as {} but not the 'from' value in parameter 3.\nPlease check and re-try".format(toValue))
    return 44
    else:
    print ("You need to provide 'to' and 'from values in parameters 3 & 4.\nPlease check and try again.")
    return 45
    else:
    if not toValue:
    print ("You have provided the 'from' value as {} but not the 'to' value in parameter 4.\nPlease check and re-try".format(fromValue))
    return 55


    print("amendSelectedField starting for field {} which is {}, aiming to change '{}' to '{}'".format(select_field_name, fieldDescription, fromValue, toValue))

    affectedField = client.get("/types/incident/fields/{}".format(select_field_name))

    if not affectedField:
    print("The field {} could not be found - please check and retry.")
    return 100

    if affectedField["input_type"] != "select" and affectedField["input_type"] != "multiselect":
    print(
    "Found field {} but it is of type {} and this program can only handle select or multiselect fields, so quitting!",
    format(select_field_name, affectedField["input_type"]))
    return 300

    valid_values = []
    deprecated_values = []
    foundInValidVals = False
    foundInInvalidVals = False

    for thisVal in affectedField["values"]:
    if thisVal["enabled"]:
    if fromValue == thisVal["label"]:
    foundInValidVals = True
    valid_values.append(thisVal)
    else:
    if fromValue == thisVal["label"]:
    foundInInvalidVals = True
    deprecated_values.append(thisVal)

    if (
    'valid_values' in locals() or 'valid_values' in globals()) and valid_values is not None and not valid_values:
    print(" This field appears to have NO valid values - please check.")
    return 101
    else:
    print (" This field has {} valid values:".format(len(valid_values)))
    for validValue in valid_values:
    print(" '{}' has value: {} and UUID: {}".format(validValue["label"], str(validValue["value"]),
    validValue["uuid"]))

    if (
    'deprecated_values' in locals() or 'deprecated_values' in globals()) and deprecated_values is not None and not deprecated_values:
    print(" For this field found NO deprecated/disabled values")
    else:
    print(" Found {} deprecated/deleted value(s) in this field:".format(len(deprecated_values)))
    for deprecatedValue in deprecated_values:
    print(" '{}' has value: {} and UUID: {}".format(deprecatedValue["label"],
    str(deprecatedValue["value"]),
    deprecatedValue["uuid"]))

    if foundInInvalidVals:
    print ("Found the 'from' value '{}' as a deleted option in this field - abandoning alteration.".format(fromValue))
    return 321

    if foundInValidVals:
    if cleanup_permitted:

    # Take a precautionary export of current settings...
    export_post = {
    "phases_and_tasks": True,
    "actions": True,
    "layouts": True,
    "notifications": True,
    "timeframes": False,
    "breach_data": False
    }
    settings = client.post("/configurations/exports", export_post)
    dumpfilename = "settings-{}-{}.res".format(self.opts["host"].split(".")[0],
    time.strftime("%Y%m%d-%H%M%S"))
    with open(dumpfilename, "wt") as settings_res:
    json.dump(settings, settings_res)

    print("++++ Cleanup started - precautionary export of fields and settings to file: {} ++++".format(dumpfilename))

    affectedField = client.get("/types/incident/fields/{}".format(select_field_name))
    newValues = []
    for thisValue in affectedField["values"]:
    if thisValue["label"] == fromValue:
    thisValue["label"] = toValue

    newValues.append(thisValue)

    def _transition(i):
    i["values"] = newValues

    client.get_put("/types/incident/fields/{}".format(select_field_name),_transition)
    print("========== PLEASE NOTE: Alteration of '{}' complete - Value '{}' has been AMENDED to '{}' ==========".format(select_field_name,fromValue,toValue))
    else:
    print("You opted not to permit an alteration of the field value\n - if required, re-run using parameter 6 as True.")
    else:
    print("The 'from' value '{}' was not found as a current field value - no alteration is appropriate.".format(fromValue))

    return 0
     I find the ability to run with cleanup_permitted = False first, to check the parameters and what the code will do before committing to update is useful.  I also value the precautionary  res file export.

    I hope you find a useful idea or two here.

    Best regards - Edwin Bolton



    ------------------------------
    Edwin Bolton
    ------------------------------



  • 6.  RE: Get the list of values for a Select Field

    Posted Tue June 09, 2020 02:39 PM
    Hi Edwin,
    I appreciate your thorough submission. 
    Will try it out and revert.

    Thanks,

    ------------------------------
    Apronti Gilbert
    ------------------------------