
    9Yf                     `    d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm	Z	  G d de
      Zd Zy)    N)api)report_errorsreport_warnings)pretty_jsonc                   \    e Zd Zed        Zed        Zed        Zed        Zed        Zy)DashboardClientc                    |j                  dd      }|j                  dd      }d|_        |j                  dd	      }|j                  d
d       |j                  ddd       |j                  dddgd       |j                  dd       |j                  ddd       |j                  dt        d       |j                  dt        d       |j                  | j                          |j                  d!d"      }|j                  d#d$       |j                  d
d%       |j                  dd&d       |j                  dddgd       |j                  dd       |j                  ddd       |j                  dt        d       |j                  dt        d       |j                  | j                          |j                  d'd(      }|j                  d#d)       |j                  | j                          |j                  d*d+      }|j                  d#d,       |j                  | j                          y )-N	dashboardz#Create, edit, and delete dashboards)helpVerbsverb)titledestTpostzCreate dashboardsr   ztitle for the new dashboardwidgetsz@widget definitions as a JSON string. If unset, reads from stdin.?)r   nargslayout_typeorderedfreezLayout type of the dashboard.)choicesr   z--descriptionz"Short description of the dashboardz--read_onlyz`Whether this dashboard is read-only. If True, only the author and admins can make changes to it.
store_true)r   actionz--notify_listzLA json list of user handles, e.g. '["user1@domain.com", "user2@domain.com"]')typer   z--template_variablesziA json list of template variable dicts, e.g. '[{"name": "host", "prefix": "host", "default": "my-host"}]')funcupdatezUpdate existing dashboardsdashboard_idz,Dashboard to replace with the new definitionzNew title for the dashboardz?Widget definitions as a JSON string. If unset, reads from stdinshowzShow a dashboard definitionzDashboard to showdeletezDelete dashboardszDashboard to delete)

add_parseradd_subparsersrequiredadd_argument_json_stringset_defaults_post_update_show_delete)cls
subparsersparserverb_parserspost_parserupdate_parsershow_parserdelete_parsers           Z/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/datadog/dogshell/dashboard.pysetup_parserzDashboardClient.setup_parser   s   &&{9^&_,,7,H $"--f;N-O  /L M  ail 	! 	
 	  F8KRq r  7[ \  v 	! 	

 	  d 	! 	

 	  "' 	! 	
 	  cii 0$//?[/\"">8i"j""71N"O""`hk 	# 	
 	""=9f:MTs"t""?9]"^""v 	# 	

 	""d 	# 	

 	"""' 	# 	
 	"""4"--f;X-Y  6I J  cii 0$//?R/S"">8M"N"""4    c                    |j                   t        _        |j                  }|j                  }|j                  t
        j                  j                         }t        j                  |      }|j                  ||j                  d}|j                  r|j                  |d<   |j                  r|j                  |d<   |j                  r|j                  |d<   |j                  r|j                  |d<   t        j                   j"                  di |}t%        |       t'        |       |dk(  rt)        t+        |             y t)        t        j,                  |             y )Nr   r   r   descriptionis_read_onlynotify_listtemplate_variablespretty )timeoutr   _timeoutformatr   sysstdinreadjsonloadsr   r   r7   	read_onlyr9   r:   	Dashboardcreater   r   printr   dumpsr*   argsr?   r   payloadress         r2   r&   zDashboardClient._postZ   s   ||,,<<iinn&G**W% !JJ74K[K[\%)%5%5GM">>&*nnGN#%)%5%5GM""",0,C,CG()mm""-W-cX+c"#$**S/"r4   c                    |j                   t        _        |j                  }|j                  }|j                  t
        j                  j                         }t        j                  |      }|j                  ||j                  d}|j                  r|j                  |d<   |j                  r|j                  |d<   |j                  r|j                  |d<   |j                  r|j                  |d<   t        j                   j"                  |j$                  fi |}t'        |       t)        |       |dk(  rt+        t-        |             y t+        t        j.                  |             y )Nr6   r7   r8   r9   r:   r;   )r=   r   r>   r?   r   r@   rA   rB   rC   rD   r   r   r7   rE   r9   r:   rF   r   r   r   r   rH   r   rI   rJ   s         r2   r'   zDashboardClient._updatew   s   ||,,<<iinn&G**W% !JJ74K[K[\%)%5%5GM">>&*nnGN#%)%5%5GM""",0,C,CG()mm""4#4#4@@cX+c"#$**S/"r4   c                 4   |j                   t        _        |j                  }t        j                  j                  |j                        }t        |       t        |       |dk(  rt        t        |             y t        t        j                  |             y )Nr;   )r=   r   r>   r?   rF   getr   r   r   rH   r   rC   rI   )r*   rK   r?   rM   s       r2   r(   zDashboardClient._show   se    ||mm 1 12cX+c"#$**S/"r4   c                     |j                   t        _        t        j                  j	                  |j
                        }|t        |       t        |       y y )N)r=   r   r>   rF   r   r   r   r   )r*   rK   rM   s      r2   r)   zDashboardClient._delete   sA    ||mm""4#4#45?C # r4   N)	__name__
__module____qualname__classmethodr3   r&   r'   r(   r)   r<   r4   r2   r   r      sg    E5 E5N # #8 # #8 
# 
#  r4   r   c                 r    	 t        j                  |       S # t        $ r t        j                  d      w xY w)Nzbad json parameter)rC   rD   	ExceptionargparseArgumentTypeError)strs    r2   r$   r$      s6    ?zz# ?(()=>>?s    6)rC   r@   rX   datadogr   datadog.dogshell.commonr   r   datadog.util.formatr   objectr   r$   r<   r4   r2   <module>r_      s1   
  
   B +Vf Vr?r4   