@tehseen (Tehseen Hussain) posted a new topic, subject "API calls without defining the name". It read:

   I'm using the API to disable monitors and I was hoping to find a way to not define the name of each monitor, where I want to loop over 5 UUID's and it makes it difficult to loop the names in as well.

Then @Limey (Richard England) said

    If I understand correctly you are using a command as described in Manage Synthetics monitors via the REST API to disable the monitor.
    
    It is necessary to send the command with the entire JSON object with the “status” set to disabled/enabled as needed.
    
    If you would like, we can submit a Feature Request to have this changed to reduce the amount of data necessary.

Then @stefan_garnham (Stefan Garnham) said

    I would like to add my +1 for this API feature @Limey. Being able to turn monitors on and off during deployments using either the guid or name would be extremely helpful.
    
    Example usage could be:
    [code] 
        curl -v 
             -X PUT -H 'X-Api-Key:{Admin_User_Key}' 
             -H 'Content-Type: application/json' https://synthetics.newrelic.com/synthetics/api/v1/monitors/status
             -d '{  "name" : "monitor1", "status" : "disabled", }'
        
        curl -v 
             -X PUT -H 'X-Api-Key:{Admin_User_Key}' 
             -H 'Content-Type: application/json' https://synthetics.newrelic.com/synthetics/api/v1/monitors/status
             -d '{  "uuid" : "{monitor_uuid}", "status" : "enabled", }'
    [/code]

Then @stefan_garnham (Stefan Garnham) said

    I'd also like to request the ability to get monitors matching multiple labels. For example:
    [code] 
        curl -v 
             -H 'X-Api-Key:{Admin_User_Key}' 
             -H 'Content-Type: application/json' https://synthetics.newrelic.com/synthetics/api/v1/monitors/labels/
             -d '{  "labels"  :  [ "Environment:Production", "Stack:PHP" ]  }'
    [/code]

@Limey (Richard England) replied

    I have submitted a feature request for both Stefan and Tehseen for a more simplified technique to disable a monitor.
    
    I've included Stefan's suggestion for a new end point as well.
    
    Thank you for the suggestions.

Then @Limey (Richard England) said

    I've also submitted a request for listing by multiple labels.
    
    Thanks for the great suggestions.

To which @tehseen (Tehseen Hussain) replied

    Thank you, yeah, the feature would help as the name is tied to the UUID in my mind.

To which @tehseen (Tehseen Hussain) replied

    Is there a location to see status on feature requests?

So @Linds (Lindsay Olson) replied

    No there is not—@tehseen. We _do try_ to update in every feature request forum thread. Keep your eyes peeled!

@peter.jones (Peter Jones) replied

    +1 for this feature request. Working on problem now of needing to supress/disable monitors during deployment. We use jenkins to do ci/cd so the jenkins job does deployment. Would like simple way to disalbe monitor given a tag, name or id of one of more monitors.
    
    Thinking same pattern/syntax as @stefan_garnham's March 18th post.

To which @SamusSam (Sam McGahan) replied

    @peter.jones Thanks for the input! I have added your +1.

@tehseen (Tehseen Hussain) replied

    So, this is for the most part fixed in V3, however, now my curl just hangs after a PUT or a PATCH, I'm having to put a timeout after each request.

To which @tehseen (Tehseen Hussain) replied

    When the cURL runs against the API, we see that it tries to download and keeps a connection open during that download so we never receive a return from the API as it never closes that connection. I'm using a workaround for now.

@acuffe (Aidan Cuffe) replied

    @tehseen I see you created a thread of your own. Lets keep the discussion there, I asked for a private message of your curl command as I'd like to investigate what problems you are having there.
    
    Thanks!!

After which, @tehseen (Tehseen Hussain) added

    Thanks, the API is running correctly, it closes the connection as required now and my stuff is successful, Thank you.

@hross (Hross) replied

    


{'source': 'discourse', 'url': 'https://discuss.newrelic.com/t/api-calls-without-defining-the-name/35652', 'title': 'API calls without defining the name', 'views': 5573, 'has_accepted_answer': False, 'word_count': 597, 'like_count': 7, 'reply_count': 4, 'participant_count': 7, 'posts': 16, 'tags': 'api', 'author': '@tehseen (Tehseen Hussain)', 'participants': '@tehseen (Tehseen Hussain), @Limey (Richard England), @stefan_garnham (Stefan Garnham), @Linds (Lindsay Olson), @peter.jones (Peter Jones), @SamusSam (Sam McGahan), @acuffe (Aidan Cuffe), @hross (Hross)', 'image_url': [None], 'created_at': '2016-03-17T16:03:02.132Z', 'last_posted_at': '2020-07-15T21:47:02.015Z'}