This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Change Display name via API

Hi community,

I have been trying to change a system display name in the NPM console but I can't find the right method on the Solarwinds API to do so.

Here's my code snippet:

swis = SwisClient(server, username, password)
results = swis.query("SELECT Uri FROM Orion.Nodes WHERE NodeID=@id", id=9)

swis.update(uri + '/NodeProperties', DisplayName='My new name')
obj = swis.read(uri + '/NodeProperties')

Obviously the /NodeProperties method doesn't exist, that was my attempt to get it to work.

Which would be the method/API call that allows to modify or edit a system property?

Thank you.

RG-

Parents
  • You are close,  the NodeProperties method is not needed as you are updating Orion.Nodes directly. If you use SWQL Studio you will notice that Display Name is stored as Caption.

    For your example, you could try this.

    swis.update(uri, Caption='My new name')

    These examples will also achieve what you want.

    1. Powershell

    # Connect to SWIS
    Import-Module SwisPowerShell
    Add-PSSnapin SwisSnapin
    $hostname = ""
    $swis = Connect-Swis -Hostname $hostname
    
    #----------------------------------------------------------#
    
    #1. Define the node attributes to be updated.
    $NodeSettings = @{  
        Caption= 'PS_API_WAS_HERE';
    }
    
    #get the URI for the node.
    $Query = 'select uri from Orion.Nodes where nodeid=21934';
    $Uri = get-swisData $swis $Query
    
    #3. Update the node
    Set-SwisObject $swis $Uri -Properties $NodeSettings

    2. Python

    __author__ = "Tony Johnson"
    import requests
    from orionsdk import SwisClient
    
    requests.packages.urllib3.disable_warnings()
    
    orion_server= ''
    username = ''
    password = ''
    swis = SwisClient(orion_server, username, password)
    
    
    def update_node():
        nodeinfo = swis.query("select Uri from Orion.Nodes where nodeid=21934")
        node_uri = nodeinfo['results'][0]['Uri']
        update_repsonse = swis.update(node_uri,caption='Python API Was here' )
    
    update_node()
    

  • Thank you . It worked perfectly!  Clap

Reply Children
No Data