
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SS
KJr  SSKJr  SSKJr  SSKJr  \R@                  " \RB                  RD                  \RB                  RF                  5       " S S\RH                  5      5       r%\RL                  \R@                  " \RB                  RN                  5       " S S\RP                  5      5       5       r)g)z2Implements command to delete an ops agents policy.    )absolute_import)division)unicode_literals)encoding)
exceptions)cloud_ops_agents_util)9os_policy_assignment_to_cloud_ops_agents_policy_converter)guest_policy_validator)utils)base)parser_utils)log)
properties)osconfig_v1_messagesc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
DeleteAlphaBeta$   a  Delete a Google Cloud's operations suite agents (Ops Agents) policy.

*{command}* deletes a policy that facilitates agent management across
Compute Engine instances based on user specified instance filters. This policy
installs, specifies versioning, enables autoupgrade, and removes Ops Agents.

The command returns a response indicating whether the deletion succeeded.
After a policy is deleted, it takes 10-15 minutes to be wiped from the
applicable instances. Deleting a policy does not delete any existing agents
managed by that policy, but the agents become unmanaged by any policies. To
remove the agents from the
instances, first update the policy to set the agent ``package-state'' to
``removed'', wait for the policy to take effect, then delete the policy.
{description}z          To delete an Ops agents policy named ``ops-agents-test-policy'' in the
          current project, run:

            $ {command} ops-agents-test-policy
          DESCRIPTIONEXAMPLESc                 0    [         R                  " U 5        g)See base class.N)r   AddSharedArgsparsers    ;lib/surface/compute/instances/ops_agents/policies/delete.pyArgsDeleteAlphaBeta.Args?   s     v&    c                    U R                  5       n[        R                  " USS9n[        R                  " USS9n[        R
                  R                  R                  R                  5       n[        R                  " SXQR                  5      nUR                  nUR                  US9n UR                  U5      n	[&        R(                  " U	5      (       d  ["        R$                  " UR                  S9eUR+                  US9n
UR-                  U
5      n[.        R0                  " UR                  5        U$ ! [        R                    a    ["        R$                  " UR                  S9ef = f)r   v1beta)api_version_overrideprojectsname)	policy_id)ReleaseTrackosconfig_api_utilsGetClientInstanceGetClientMessagesr   VALUEScoreproject	GetOrFailosconfig_command_utilsGetGuestPolicyUriPath	POLICY_IDprojects_guestPolicies'OsconfigProjectsGuestPoliciesGetRequestGetapitools_exceptionsHttpNotFoundErrorops_agents_exceptionsPolicyNotFoundErrorr
   IsOpsAgentPolicy*OsconfigProjectsGuestPoliciesDeleteRequestDeleter   DeletedResource)selfargsrelease_trackclientmessagesr.   guest_policy_uri_pathserviceget_requestget_responsedelete_requestdelete_responses               r   RunDeleteAlphaBeta.RunD   sI   %%'M11HF "33HH $$,,668G2HHG^^ ++GBB" C KP[[-l "22<@@!55OOHH" I N nn^4O' 00 P!55OOPs   *D6 63E) N
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   rI   __static_attributes__rK   r    r   r   r   $   s1      %- ' 'r    r   c                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
r<   f   a  Delete a Google Cloud Observability agents policy for the Ops Agent.

*{command}* deletes a policy that facilitates agent management across
Compute Engine instances based on user specified instance filters.

The command returns a response indicating whether the deletion succeeded.
After a policy is deleted, it takes 10-15 minutes to be wiped from the
applicable instances. Deleting a policy does not delete any existing agents
managed by that policy, but the agents become unmanaged by any policies. To
remove the agents from the instances, first update the policy to set the
agent ``packageState'' to ``removed'', wait for the policy to take effect,
then delete the policy.

The command returns the content of the deleted policy. For instance:

  agentsRule:
    packageState: installed
    version: latest
  instanceFilter:
    inclusionLabels:
    - labels:
        env: prod

If no policies are found, or the policy is not an agents policy, then the
command returns a ``NOT_FOUND'' error.
r   z          To delete an agents policy named ``ops-agents-test-policy'' in the
          current project, run:

          $ {command} ops-agents-test-policy --zone=ZONE
          r   c                 P    U R                  S[        SS9  U R                  SSSS9  g)	r   r2   z          ID of the policy.

          This ID must contain only lowercase letters,
          numbers, and hyphens, end with a number or a letter, be between 1-63
          characters, and be unique within the project.
          )typehelpz--zoneTz7          Zone of the agents policy you want to delete.)requiredrY   N)add_argumentstrr   s    r   r   Delete.Args   sB       
 ;  r    c                    U R                  5       n[        R                  R                  R                  R                  5       n[        R                  " X!R                  X1R                  5      n[        R                  " X1R                  5      n[        R                  " XQR                  5      n[        R                  " U5      nUR                  US9n[        R                   " U5      n	U	R"                  n
U
R%                  U5      n[&        R(                  " [*        R,                  [&        R.                  " UR0                  5      5      n[2        R4                  " U5      nUR7                  5       $ )r   r%   )r(   r   r,   r-   r.   r/   r   GetOpsAgentsPolicyFromApir2   zoner0   GetProjectLocationUriPath!GetOsPolicyAssignmentRelativePathr)   r+   9OsconfigProjectsLocationsOsPolicyAssignmentsDeleteRequestr*   &projects_locations_osPolicyAssignmentsr<   r   PyValueToMessageosconfigOSPolicyAssignmentMessageToPyValueresponseto_ops_agents_policy/ConvertOsPolicyAssignmentToCloudOpsAgentsPolicy	ToPyValue)r>   r?   r@   r.   _parent_pathassignment_idrB   rG   rA   rD   rH   delete_os_policy_assignmentops_agents_policys                 r   rI   
Delete.Run   s3    %%'M$$,,668G77~~w			A )BBK +LL^^M "33MBHJJ 	K 	
   11-@F;;Gnn^4O #+";";##!!/":":;#
 	LL'	
 
 &&((r    rK   NrL   rK   r    r   r<   r<   f   s1    8 %-  (()r    r<   N)*rQ   
__future__r   r   r   apitools.base.pyr   r   r6   3googlecloudsdk.api_lib.compute.instances.ops_agentsr   r8   >googlecloudsdk.api_lib.compute.instances.ops_agents.convertersr	   rj   >googlecloudsdk.api_lib.compute.instances.ops_agents.validatorsr
   (googlecloudsdk.api_lib.compute.os_configr   r)   googlecloudsdk.callioper   @googlecloudsdk.command_lib.compute.instances.ops_agents.policiesr   ,googlecloudsdk.command_lib.compute.os_configr0   googlecloudsdk.corer   r   1googlecloudsdk.generated_clients.apis.osconfig.v1r   rf   ReleaseTracksr(   BETAALPHADeleteCommandr   UniverseCompatibleGACommandr<   rK   r    r   <module>r      s    9 &  ' % > U c ] a P ( Y X # * ^ D%%**D,=,=,C,CD>d(( > E>B D%%(()c)T\\ c) * c)r    