
                        (   S r SSKrSSKrSSKrSSKrSSK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rSrSrSrSrSrSrSrSrSrSr Sr!Sr"Sr#Sr$Sr%Sr&\'" 1 Sk5      r(Sr)S r*S!r+S"r,S#r-S$r.S%S&0r/ " S' S(\R`                  5      r1S) r2S* r3S+ r4S, r5S- r6S. r7S/\8S0\84S1 jr9S/\8S0\84S2 jr:SxS/\8S3\84S4 jjr;SxS/\8S3\84S5 jjr<S6 r=S7 r>S8\R~                  4S9 jr@ SyS: jrASyS; jrB SyS< jrCS=\R~                  4S>\8S?\8S@\DSA\D4SB jjrE SzS>\8S?\8S@\D4SC jjrFSzS>\8S?\8S@\D4SD jjrGSzS>\8S0\8S@\D4SE jjrHSF rI   S{SG\JSH\JSI\J4SJ jjrKSK\8SL\84SM jrLSK\8SL\84SN jrM     S|SO\\8   SP\8SQ\8SR\8SS\8SG\JST\J4SU jjrN  S}S0\8SP\8SR\8SS\84SV jjrO       S~SP\8SO\\8   SQ\8SI\JSR\8SS\8SG\JSW\JSX\J4SY jjrP   SSP\8S0\8SZ\8SR\8SS\84
S[ jjrQS\ rRS] rSSS^ jrTS_ rUS` rV " Sa Sb5      rW  S}SP\8Sc\JS@\DSA\DSR\8SS\84Sd jjrX  S}SP\8Sc\JS@\DSA\DSR\8SS\84Se jjrYSf rZS/\84Sg jr[S/\84Sh jr\S/\84Si jr]Sj\^\8   4Sk jr_\1R                  4Sl jraS}Sm jrb SSn jrc SSo jrdSp reSq rfSr rgSsSt\R~                  4Su jrhSsSt\R~                  4Sv jriSSw jrjg)zservices helper functions.    N)List)encoding)
exceptions)
list_pager)services_util)apis_internal)
http_retry)log)
properties)	transportzprojects/%sz
folders/%szorganizations/%szprojects/%s/services/%szfolders/%s/services/%szorganizations/%s/services/%szservices/%sz/groups/dependenciesz/reverseClosurez%s/services/%sz/consumerPolicies/%sz/mcpPolicies/%szmcp_server:urlsz/effectivePolicyz/effectiveMcpPolicyzcategories/googlez%s/consumerOverrides/%s>   folders/	projects/organizations/v1v1beta1v1alphav2alphav2betai  zanthos.googleapis.comz\Warning: Disabling this service will also automatically disable any running Anthos clusters.c                   $    \ rS rSrSrSrSrSrSrg)ContainerTypeE   zReturn the container type.          N)	__name__
__module____qualname____firstlineno____doc__PROJECT_SERVICE_RESOURCEFOLDER_SERVICE_RESOURCEORG_SERVICE_RESOURCE__static_attributes__r       3lib/googlecloudsdk/api_lib/services/serviceusage.pyr   r   E   s    "r%   r   c                 ,    [         R                  U 5      $ )z?Return the warning message associated with a protected service.)_PROTECTED_SERVICESget)service_names    r&   GetProtectedServiceWarningr+   L   s    		 	 	..r%   c                     SU  S3$ )z?Return the error message associated with a MCP enabled service.zrTo enable the MCP endpoint, the service must be enabled first. Do you want to enable the service for the resource ?r   )resource_names    r&   GetMcpEnabledErrorr/   Q   s    

r%   c                 6   [        [        S9nUR                  nUR                  U S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a   Make API call to get a consumer policy.

Args:
  policy_name: The name of a consumer policy. Currently supported format
    '{resource_type}/{resource_name}/consumerPolicies/default'. For example,
    'projects/100/consumerPolicies/default'.

Raises:
  exceptions.GetConsumerPolicyPermissionDeniedException: when getting a
    consumer policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  message.GoogleApiServiceusageV2betaConsumerPolicy: The consumer policy
versionnameN)_GetClientInstance_V2BETA_VERSIONMESSAGES_MODULE&ServiceusageConsumerPoliciesGetRequestconsumerPoliciesGetapitools_exceptionsHttpForbiddenErrorHttpNotFoundErrorr   ReraiseErrorGetConsumerPolicyExceptionpolicy_nameclientmessagesrequestes        r&   GetConsumerPolicyV2BetarF   Z   s      o6&##(;;;M'F""&&w//,,++
 F AzDDEE	F   A $B)%BBc                 :   [        [        5      nUR                  nUR                  U S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get a MCP policy.

Args:
  policy_name: The name of a MCP policy. Currently supported format
    '{resource_type}/{resource_name}/mcpPolicies/default'. For example,
    'projects/100/mcpPolicies/default'.

Raises:
  exceptions.GetMcpPolicyException: when getting a
    MCP policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The MCP policy
r3   N)r5   r6   r7   !ServiceusageMcpPoliciesGetRequestmcpPoliciesr:   r;   r<   r=   r   r>   GetMcpPolicyExceptionr@   s        r&   GetMcpPolicyrL   x   s      o.&##(66K6H'A!!'**,,++
 A Az??@@	A   A $B+%BBc                 :   [        [        5      nUR                  nUR                  U S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get the content security policy for a given project, folder or organization.

Args:
  name: The name of a content security policy. Currently supported format
    '{resource_type}/{resource_name}/contentSecurityPolicies/default'. For
    example, 'projects/100/contentSecurityPolicies/default'.

Raises:
  exceptions.GetContentSecurityPolicyException: when getting a
    content security policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The content security policy.
r3   N)r5   r6   r7   -ServiceusageContentSecurityPoliciesGetRequestcontentSecurityPoliciesr:   r;   r<   r=   r   r>   !GetContentSecurityPolicyExceptionr4   rB   rC   rD   rE   s        r&   GetContentSecurityPolicyrS      s      o.&##(BBBM'M))--g66,,++
 M AzKKLL	MrM   c                 :   [        [        5      nUR                  nUR                  XS9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)ac  Make API call to update the content security policy for a given project, folder or organization.

Args:
  name: The name of a content security policy. Currently supported format
    '{resource_type}/{resource_name}/contentSecurityPolicies/default'. For
    example, 'projects/100/contentSecurityPolicies/default'.
  content_security_policy: The content security policy to update.

Raises:
  exceptions.UpdateContentSecurityPolicyException: when updating a
    content security policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The content security policy.
)r4   contentSecurityPolicyN)r5   r6   r7   /ServiceusageContentSecurityPoliciesPatchRequestrP   Patchr;   r<   r=   r   r>   $UpdateContentSecurityPolicyException)r4   content_security_policyrB   rC   rD   rE   s         r&   UpdateContentSecurityPolicyrZ      s    " o.&##(DD E 'P))//88,,++
 P AzNNOO	PrM   r4   servicec                 V   [        [        5      nUR                  nUR                  U UR	                  US9S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a0  Make API call to test MCP enabled.

Args:
  name: Parent resource to test a value against the result of merging MCP
    policies in the resource hierarchy. Format: "projects/{PROJECT_ID}" (e.g.,
    "projects/foo-bar"), "projects/{PROJECT_NUMBER}" (e.g.,
    "projects/12345678"), "folders/{FOLDER_NUMBER}" (e.g., "folders/1234567")
    , "organizations/{ORGANIZATION_NUMBER}" (e.g., "organizations/123456").
  service: Service name to check if the targeted resource can use this service
    for MCP. Current supported value: services/{SERVICE_NAME} (format:
    "services/{service}").

Raises:
  exceptions.TestMcpEnabledException: when testing value for a
    service and resource.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.State: The state of the service.
serviceName)r4   testMcpEnabledRequestN)r5   r6   r7   !ServiceusageTestMcpEnabledRequestTestMcpEnabledRequestr   TestMcpEnabledr;   r<   r=   r   r>   TestMcpEnabledExceptionr4   r[   rB   rC   rD   rE   s         r&   rb   rb      s    * o.&##(66$::w:O 7 '
C==''00,,++
 C AzAABB	C   A $B(9%B##B(c                 V   [        [        5      nUR                  nUR                  U UR	                  US9S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)af  Make API call to test enabled.

Args:
  name: Parent resource to test a value against the result of merging consumer
    policies in the resource hierarchy. format-"projects/100", "folders/101"
    or "organizations/102".
  service: Service name to check if the targeted resource can use this
    service. Current supported value: SERVICE (format: "services/{service}").

Raises:
  exceptions.TestEnabledPermissionDeniedException: when testing value for a
    service and resource.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.State: The state of the service.
r]   )r4   testEnabledRequestN)r5   r6   r7   ServiceusageTestEnabledRequestTestEnabledRequestr   TestEnabledr;   r<   r=   r   r>   TestEnabledExceptionrd   s         r&   rj   rj      s    $ o.&##(33!444I 4 '
@==$$W--,,++
 @ Az>>??	@re   viewc                    [        [        S9nUR                  nUS:X  a!  UR                  R                  R
                  nO UR                  R                  R                  nUR                  XS9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get a effective policy.

Args:
  name: The name of the effective policy.Currently supported format
    '{resource_type}/{resource_name}/effectivePolicy'. For example,
    'projects/100/effectivePolicy'.
  view: The view of the effective policy to use. The default view is 'BASIC'.

Raises:
  exceptions.GetEffectivePolicyException: when getting a
    effective policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  message.EffectivePolicy: The effective policy
r1   BASICr4   rl   N)r5   r6   r7   %ServiceusageGetEffectivePolicyRequestViewValueValuesEnumEFFECTIVE_POLICY_VIEW_BASICEFFECTIVE_POLICY_VIEW_FULLr   GetEffectivePolicyr;   r<   r=   r   r>   GetEffectivePolicyExceptionr4   rl   rB   rC   	view_typerD   rE   s          r&   GetEffectivePolicyV2Betarx     s    " o6&##(	W_66JJff 
 	66JJee  :: ; 'G==++G44,,++
 G AzEEFF	G   1B $C0%CCc                    [        [        S9nUR                  nUS:X  a!  UR                  R                  R
                  nO UR                  R                  R                  nUR                  XS9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a/  Make API call to get a effective MCP policy.

Args:
  name: The name of the effective MCP policy. Currently supported format
    '{resource_type}/{resource_name}/effectiveMcpPolicy'. For example,
    'projects/100/effectivePolicy'.
  view: The view of the effective MCP policy to use. The default view is
    'BASIC'.

Raises:
  exceptions.GetEffectiveMcpPolicyException: when getting a
    effective policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  message.EffectiveMcpPolicy: The effective MCP policy
r1   rn   ro   N)r5   r6   r7   (ServiceusageGetEffectiveMcpPolicyRequestrq   EFFECTIVE_MCP_POLICY_VIEW_BASICEFFECTIVE_MCP_POLICY_VIEW_FULLr   GetEffectiveMcpPolicyr;   r<   r=   r   r>   GetEffectiveMcpPolicyExceptionrv   s          r&   r~   r~   G  s    $ o6&##(	W_99MMmm 
 	99MMll  == > 'J==..w77,,++
 J AzHHII	Jry   c                 t   [        [        S9nUR                  nUR                  U UR                  R                  R
                  S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get service state for a service .

Args:
  service: Service. Current supported value:(format:
    "{resource}/{resource_Id}/services/{service}").

Raises:
  exceptions.GetServiceException: when getting service
    service state for service in the resource.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.GetServicesResponse: Service state of the given resource.
r1   ro   N)r5   r6   r7   ServiceusageServicesGetRequestrq   SERVICE_STATE_VIEW_FULLservicesr:   r;   r<   r=   r   r>   GetServiceException)r[   rB   rC   rD   rE   s        r&   GetServiceV2Betar   q  s     o6&##(3322FF^^ 4 '
???w'',,++
 ? Az==>>	?s   	A$ $$B7%B22B7c                 v   [        [        S9nUR                  nUR                  U UUR                  R                  R
                  S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a7  Make API call to get service state for multiple services .

Args:
  parent: Parent resource to get service state for. format-"projects/100",
    "folders/101" or "organizations/102".
  services: Services. Current supported value:(format:
    "{resource}/{resource_Id}/services/{service}").

Raises:
  exceptions.BatchGetServiceException: when getting batch
    service state for services in the resource.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.BatchGetServicesResponse: Service state of the given resource.
r1   )parentr   rl   N)r5   r6   r7   #ServiceusageServicesBatchGetRequestrq   r   r   BatchGetr;   r<   r=   r   r>   BatchGetServiceException)r   r   rB   rC   rD   rE   s         r&   BatchGetServicer     s    " o6&##(8877KKcc 9 'D??##G,,,,++
 D AzBBCC	Ds   
A% %$B8	%B33B8   c           	      v   [        [        S9nUR                  nUR                  SR	                  X5      S9n [
        R                  " [        UR                  5      UUSUSS9$ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)aX  Make API call to list category services .

Args:
  resource: resource to get list for. format-"projects/100", "folders/101" or
    "organizations/102".
  category: category to get list for. format-"catgeory/<category>".
  page_size: The page size to list.default=200
  limit: The max number of services to display.

Raises:
  exceptions.ListCategoryServicesException: when listing the
  services the parent category includes.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.ListCategoryServicesResponse: The services the parent category
  includes.
r1   {}/{}r   pageSizer   limitbatch_size_attribute
batch_sizefieldN)r5   r6   r7   1ServiceusageCategoriesCategoryServicesListRequestformatr   YieldFromList_Listercategories_categoryServicesr;   r<   r=   r   r>   ListCategoryServicesException)resourcecategory	page_sizer   rB   rC   rD   rE   s           r&   ListCategoryServicesr     s    & o6&##(FF^^H/ G 'I##223'  ,,++
 I AzGGHH	Is   +A% %$B8	%B33B8c                    [        S5      nUR                  nUR                  U UUUS9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAf[
        R                   aN  n[        R                  R                  S5        [        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to update a consumer policy.

Args:
  consumerpolicy: The consumer policy to update.
  name: The resource name of the policy. Currently supported format
    '{resource_type}/{resource_name}/consumerPolicies/default. For example,
    'projects/100/consumerPolicies/default'.
  force: Disable service with usage within last 30 days or disable recently
    enabled service.
  validateonly: If set, validate the request and preview the result but do not
    actually commit it. The default is false.

Raises:
  exceptions.UpdateConsumerPolicyPermissionDeniedException: when updating a
    consumer policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Updated consumer policy
r   )*googleApiServiceusageV2alphaConsumerPolicyr4   forcevalidateOnlyN?Provide the --force flag if you wish to force disable services.)r5   r7   (ServiceusageConsumerPoliciesPatchRequestr9   rW   r;   r<   r=   r   r>   UpdateConsumerPolicyExceptionHttpBadRequestErrorr
   statusPrintErrorconsumerpolicyr4   r   validateonlyrB   rC   rD   rE   s           r&   UpdateConsumerPolicyV2Alphar     s    . i(&##(==1?	 > '1""((11,,++
 I AzGGHH		0	0 1JJI Az//00	1s$   A $C9*%BC9+AC44C9c                 <   [        [        5      nUR                  nUR                  XX#S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to update a MCP policy.

Args:
  policy: The MCP policy to update.
  name: The resource name of the MCP policy. Currently supported format
    '{resource_type}/{resource_name}/mcpPolicies/default. For example,
    'projects/100/mcpPolicies/default'.
  force: Disable service with usage within last 30 days or disable recently
    enabled service.(not supported during MVP.)
  validateonly: If set, validate the request and preview the result but do not
    actually commit it. The default is false.(not supported during MVP.)

Raises:
  exceptions.class UpdateMcpPolicyException: when getting a
    MCP policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The MCP policy
)	mcpPolicyr4   r   r   N)r5   r6   r7   #ServiceusageMcpPoliciesPatchRequestrJ   rW   r;   r<   r=   r   r>   UpdateMcpPolicyException)policyr4   r   r   rB   rC   rD   rE   s           r&   UpdateMcpPolicyr     s    * o.&##(88 9 'D##G,,,,++
 D AzBBCC	Ds   A $B,%BBc                     [        [        5      nUR                  nUR                  U UUUS9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAf[        R                   aN  n[        R                  R                  S5        [        R                  " U[        R                   5         SnAgSnAff = f)a  Make API call to update a consumer policy.

Args:
  consumerpolicy: The consumer policy to update.
  name: The resource name of the policy. Currently supported format
    '{resource_type}/{resource_name}/consumerPolicies/default. For example,
    'projects/100/consumerPolicies/default'.
  force: Disable service with usage within last 30 days or disable recently
    enabled service.
  validateonly: If set, validate the request and preview the result but do not
    actually commit it. The default is false.

Raises:
  exceptions.UpdateConsumerPolicyException: when updating a
    consumer policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Updated consumer policy
))googleApiServiceusageV2betaConsumerPolicyr4   r   r   Nr   )r5   r6   r7   r   r9   rW   r;   r<   r=   r   r>   r   r   r
   r   r   r   r   s           r&   UpdateConsumerPolicyV2Betar   2  s    . o.&##(==0>	 > '1""((11,,++
 I AzGGHH		0	0 1JJI Az//00	1s$   A
 
$C=.%BC=/AC88C=2   r   service_groupr   r   c           	         [        [        5      nUR                  nUR                  U S-   U-   S9n [        R
                  " [        UR                  5      UUSUSS9n/ nU H  n	UR                  U	5        M     U$ ! [        R                  [        R                  [        R                  4 aE  n
S[        U
5      ;   a  / s Sn
A
$ [        R                  " U
[        R                   5         Sn
A
gSn
A
ff = f)az  Make API call to list group members of a specific service group.

Args:
  resource: The target resource.
  service_group: Service group which owns a collection of group members, for
    example, 'services/compute.googleapis.com/groups/dependencies'.
  page_size: The page size to list. The default page_size is 50.
  limit: The max number of services to display.

Raises:
  exceptions.ListGroupMembersPermissionDeniedException: when listing
    group members fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.ListGroupMembersResponse : Group members in the given service group.
/r   r   memberStatesr   SU_GROUP_NOT_FOUNDN)r5   r6   r7   ,ServiceusageServicesGroupsMembersListRequestr   r   r   services_groups_membersappendr;   r   r<   r=   strr   r>   ListGroupMembersException)r   r   r   r   rB   rC   rD   responsemember_statesmember_staterE   s              r&   ListGroupMembersr   a  s    . o.&##(AA^m+ B 'G''../'H M <( !--,,++
 G
 s1v%ia!E!EFFGs$   A	A< <3C4/C/?C4%C//C4c                 p   [        S5      nUR                  nUR                  SR                  X5      S9n [        R
                  " [        UR                  5      USUSS9$ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)aK  Make API call to list descendant services of a specific service group.

Args:
  resource: The target resource in the format:
    '{resource_type}/{resource_name}'.
  service_group: Service group, for example,
    'services/compute.googleapis.com/groups/dependencies'.
  page_size: The page size to list. The default page_size is 50.

Raises:
  exceptions.ListDescendantServicesPermissionDeniedException: when listing
    descendant services fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Descendant services in the given service group.
r   r   r   r   r   r   r   r   N)r5   r7   7ServiceusageServicesGroupsDescendantServicesListRequestr   r   r   r   "services_groups_descendantServicesr;   r<   r=   r   r>   ListDescendantServicesException)r   r   r   rB   rC   rD   rE   s          r&   ListDescendantServicesr     s    ( i(&##(LL^^H4 M 'K##99:'  ,,++
 K AzIIJJ	Ks   *A" "$B5%B00B5c                    [        [        5      nUR                  nUR                  SR	                  X5      S9n [
        R                  " [        UR                  5      USUSS9n/ nU H  nUR                  UR                  5        M      U$ ! [        R                  [        R                  4 aE  n	S[        U	5      ;   a  / s Sn	A	$ [        R                   " U	[        R"                  5         Sn	A	gSn	A	ff = f)af  Make API call to list expanded members of a specific service group.

Args:
  resource: The target resource in the format:
    '{resource_type}/{resource_name}'.
  service_group: Service group, for example,
    'services/compute.googleapis.com/groups/dependencies'.
  page_size: The page size to list. The default page_size is 50.

Raises:
  exceptions.ListExpandedMembersException: when listing
    expanded members fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message. ExpandedMember.serviceName : Service names of the expanded members
  of the service group.
r   r   r   membersr   r   N)r5   r6   r7   4ServiceusageServicesGroupsExpandedMembersListRequestr   r   r   r   services_groups_expandedMembersr   r^   r;   r<   r=   r   r   r>   ListExpandedMembersException)
r   r   r   rB   rC   rD   r   service_namesmemberrE   s
             r&   ListExpandedMembersr     s    & o.&##(II^^H4 J 'J''667'H M6--. ,,++
 J s1v%ia!H!HIIJs$   AB $C72C2C7%C22C7c                 \   [        S5      nUR                  nUR                  U  SU 3S9n [        R                  " [        UR                  5      USUSS9$ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a>  Make API call to list ancestor groups that depend on the service.

Args:
  resource: The target resource.format : '{resource_type}/{resource_name}'.
  service: The identifier of the service to get ancestor groups of, for
    example, 'services/compute.googleapis.com'.
  page_size: The page size to list.The default page_size is 50.

Raises:
  exceptions.ListAncestorGroupsPermissionDeniedException: when listing
    ancestor group fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Ancestor groups that depend on the service.
r   r   r3   r   groupsr   N)r5   r7   -ServiceusageServicesAncestorGroupsListRequestr   r   r   services_ancestorGroupsr;   r<   r=   r   r>   +ListAncestorGroupsPermissionDeniedException)r   r[   r   rB   rC   rD   rE   s          r&   ListAncestorGroupsr     s    " i(&##(BBZq	" C '##../'  ,,++
  	:AA 	s   *A $B+<%B&&B+c                    [        [        S9nUR                  nUR                  UR	                  U UR                  R
                  R                  /S9U R                  S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a{  Make API call to analyze a consumer policy for dependencies.

Args:
  proposed_policy: The consumer policy to analyze. type :
    message.GoogleApiServiceusageV2alphaConsumerPolicy

Raises:
  exceptions.AnalyzeConsumerPolicyException: when analyzing a
    consumer policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  message.
r1   )proposedPolicyanalysisTypes)analyzeConsumerPolicyRequestr4   N)r5   r6   r7   *ServiceusageConsumerPoliciesAnalyzeRequestAnalyzeConsumerPolicyRequest%AnalysisTypesValueListEntryValuesEnumANALYSIS_TYPE_DEPENDENCYr4   r9   Analyzer;   r<   r=   r   r>   AnalyzeConsumerPolicyException)proposed_policyrB   rC   rD   rE   s        r&   AnalyzeConsumerPolicyr     s    " o6&##(??#+#H#H(33YYrr $I $  @ 'J""**733,,++
 J AzHHII	Js   "A= =$C!%CCvalidate_onlybypass_dependency_checkr   c                    [        [        S9nUR                  n UR                  U S   S9nSU R	                  5       ;   aE  U S   b?  U S    H6  nSU;   d  M  UR
                  R                  UR                  US   S95        M8     U(       d  [        U5      n[        R                  " UR                  [        5      n[        R                  " UR                  5      n	0 n
SU	;   aX  U	S    HO  nUS	   S
    H@  nUS   U
R	                  5       ;  a  US   /XS   '   M'  XS      R                  US   5        MB     MQ     U
(       a:  SnU
 H  nX    H  nUUS-   U-   S-   -  nM     M     [         R"                  " U5      e[%        UUR                  UUS9$ ! [&        R(                  [&        R*                  4 a/  n[         R,                  " U[         R.                  5         SnAgSnAff = f)a?  Make API call to update a consumer policy.

Args:
  consumerpolicy: The consumer policy to update.
  validate_only: If True, the action will be validated and result will be
    preview but not exceuted.
  bypass_dependency_check: If True, dependencies check will be bypassed.
  force: If True, the system will bypass usage checks for services that are
    being removed.

Raises:
  exceptions.UpdateConsumerPolicyException: when updating policy API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r1   r4   r3   enableRulesNr   r   analysisanalysisResultwarningsr[   missingDependencyzPolicy cannot be updated as 
z is missing service dependency 
)r   r   )r5   r6   r7   )GoogleApiServiceusageV2betaConsumerPolicykeysr   r   %GoogleApiServiceusageV2betaEnableRuler   r   WaitOperationr4   GetOperationV2Betar   MessageToDictr   r   ConfigErrorr   r;   r<   r=   r>   r   )r   r   r   r   rB   rC   r   enable_ruleopanalysis_reponsemissing_dependenciesr   warningerror_messager[   
dependencyrE   s                    r&   UpdateConsumerPolicyr   @  s   0 o6&##(;I??F# @ F
 	,,..=)5'6+$



#
#<<&z2 =  7 # (b&&rww0BCb!//<	'	'(4H!"23J?g	"*>*C*C*EE-.;"I#67 #I#67>>-. @ 5 
8+G09j;;jH4OM : , $$]33%"	  ,,++
 I AzGGHH	Is   8F D<F $G'8%G""G'content_security_providerr.   c                    [        [        S9nUR                  n [        U5      nU R	                  S5      (       d  SU  3n UR
                  nUR                   Vs/ s H  ofR                  PM     nnX;   a  [        R                  " SU  S35      e[        R                  " U5      nUR
                  R                  R                  UR                  U S95        [        UU5      $ s  snf ! [        R                   [        R"                  4 a/  n	[        R$                  " U	[        R&                  5         Sn	A	gSn	A	ff = f)a  Make API call to add a content security provider.

Args:
  content_security_provider: The content security provider to add.
  resource_name: The resource name of the content security policy.

Raises:
  exceptions.AddContentSecurityProviderException: when adding content security
  provider to content security policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r1   	services/The content security provider z already exists.r3   N)r5   r6   r7   rS   
startswithmcpContentSecuritycontentSecurityProvidersr4   r   r   copydeepcopyr   ContentSecurityProviderrZ   r;   r<   r=   r>   #AddContentSecurityProviderException)
r   r.   rB   rC   rY   mcp_content_securityp#existing_content_security_providersupdate_policyrE   s
             r&   AddContentSecurityProviderr    sF   & o6&##(!O6}E$//<<$-.G-H"I2EE -EE+E1E ( + !G""*+D*E F  
 MM"9:M$$==DD((.G(H ' !+, ,,++
 O AzMMNN	Os+   A C* C%0A4C* %C* *$D=%D88D=c                      [        U5      nU R                  S5      (       d  SU  3n [        R                  " U5      nUR                  n/ nSnUR
                   H(  nUR                  U :X  a  SnM  UR                  U5        M*     U(       d  [        R                  " SU  S35      eUUl        [        UU5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to remove a content security provider.

Args:
  content_security_provider: The content security provider to remove.
  resource_name: The resource name of the content security policy.

Raises:
  exceptions.RemoveContentSecurityProviderException: when removing content
  security
  provider from content security policy fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r  FTr  z does not exist.N)rS   r  r  r  r  r  r4   r   r   r   rZ   r;   r<   r=   r>   &RemoveContentSecurityProviderException)	r   r.   rY   r  r  "updated_content_security_providers
is_presentr  rE   s	            r&   RemoveContentSecurityProviderr    s   ('6}E$//<<$-.G-H"IMM"9:M(;;)+&J!::	
,	,
*11!4	 ; ""*+D*E F   	+ 1 '  ,,++
  	:<< 	s   B7B: :$D%DDr   projectconsumer_policy_namefolderorganizationskip_dependencyc                    [        [        S9nUR                  n[        U-  n	U(       a	  [        U-  n	U(       a	  [
        U-  n	U	[        U-  -   n
 [        U
5      n[        5       n[        5       nUR                  (       a"  [        UR                  S   R                  5      nU  H*  n[        U-  U;  d  M  UR                  [        U-  5        M,     [        5       nU(       d  U  HS  n[        U	[        U-  [        -   5      nU H0  nUR                  S5      S   nUU ;  d  M  UR                  U5        M2     MU     [!        U5       H  nX;  d  M
  UR                  U5        M     U(       d  U(       a+  ["        R$                  " SSR'                  U 5      -   S-   5      eSR'                  U 5      nSU 3nU(       a"  SR'                  [!        U5      5      nUSU 3-  nUS-  n["        R$                  " U5      eUR                  (       a;  [!        U5       H+  nUR                  S   R                  R)                  U5        M-     O1UR                  R)                  UR+                  [!        U5      S	95        [-        XUS
9[!        U5      4$ ! [.        R0                  [.        R2                  4 a/  n["        R4                  " U["        R6                  5         SnAgSnAff = f)a$  Make API call to enable a specific service.

Args:
  services: The identifier of the service to enable, for example
    'serviceusage.googleapis.com'.
  project: The project for which to enable the service.
  consumer_policy_name: Name of consumer policy. The default name is
    "default".
  folder: The folder for which to enable the service.
  organization: The organization for which to enable the service.
  validate_only: If True, the action will be validated and result will be
    preview but not exceuted.
  skip_dependency: If True, the dependencies of the service to be enabled will
    not be enabled.

Raises:
  exceptions.EnableServiceException: when enabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r1   r   r   zThe service(s) ,z7 are already enabled and present in the consumer policyz and their dependencies r   )r   N)r5   r6   r7   _PROJECT_RESOURCE_FOLDER_RESOURCE_ORGANIZATION_RESOURCE_CONSUMER_POLICY_DEFAULTrF   setr   r   _SERVICE_RESOURCEaddr   _DEPENDENCY_GROUPsplitlistr   r   joinr   r   r   r;   r<   r=   r>   EnableServiceException)r   r  r  r  r  r   r  rB   rC   r.   rA   r   services_to_enabledexisting_servicesr[   dependent_serviceslist_expanded_membersdependent_servicedependent_service_nameservice_list_strmessagedependent_list_strrE   s                          r&   AddEnableRuler2    s   > o6&##(#g--$v-M*\9M 8;O OO+GB$[1F%f003<<=	W	$,=	= 1G ;< 
 ' 3,w69JJ!
 "7#4#:#:3#?#C
  $83""#45 "7	  ,-'+

!
!'
* .
 	$$hhx !GH
 	
 88H-#$4#56  #xx-?(@A

/0B/CD
D'LL$$W---.'1&&--g6 / 

8
8/0 9  &- ! ! ,,++
 B Az@@AA	Bs-   A"J 6A)J #*J D9J $K/%KKc                 4   [        [        S9nUR                  n[        U-  nU(       a	  [        U-  nU(       a	  [
        U-  nU[        S-  -   n [        U5      nUR                  (       a  UR                  S   R                   H6  n	U	R                  [        U -  :X  d  M  [        R                  " SU -   S-   5      e   UR                  S   R                  R                  UR                  [        U -  S95        O=UR                  R                  UR!                  UR                  [        U -  S9/S95        [#        X5      $ ! [$        R&                  [$        R(                  4 a/  n
[        R*                  " U
[        R,                  5         Sn
A
gSn
A
ff = f)	a  Make API call to enable a specific service in mcp policy.

Args:
  service: The identifier of the service to enable, for example
    'serviceusage.googleapis.com'.
  project: The project for which to enable the service.
  folder: The folder for which to enable the service.
  organization: The organization for which to enable the service.

Raises:
  exceptions.EnableServiceException: when enabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r1   defaultr   The service z is already enabled for MCP.)r[   )mcpServicesN)r5   r6   r7   r  r  r  _MCP_POLICY_DEFAULTrL   mcpEnableRulesr6  r[   r"  r   r   r   
McpServiceMcpEnableRuler   r;   r<   r=   r>   EnableMcpServiceException)r[   r  r  r  rB   rC   r.   rA   r   mcp_servicerE   s              r&   AddMcpEnableRuler=    s   , o6&##(#g--$v-M*\9M 3i ??+E+&F..q1==+"3g"==&&w&)GG  > A**11


&7'&A

B ""

 
 %%.?'.I%J !  6//,,++
 E AzCCDD	Es    AE !B"E $F(%FFskip_dependency_checkdisable_dependency_servicesc	                   ^ [         U -  n	U(       a	  [        U-  n	U(       a	  [        U-  n	U	[        U-  -   n
 [	        U
5      nU V^s1 s H+  m[        U4S jUR                   5       5      (       d  M)  TiM-     nnU Vs/ s H  oU;  d  M
  UPM     nnU(       d+  [        R                  " SSR                  U5      -   S-   5      e[        R                  " U5      nUR                   HG  nU H>  m[        T-  UR                  ;   d  M  UR                  R                  [        T-  5        M@     MI     / nU(       Gd  [        U5      n[         R"                  " UR$                  [&        5      n[(        R*                  " UR,                  5      n0 nSU;   al  US    Hc  nUS   S    HT  nU HK  m[        T-  US   :X  d  M  TU;  a  / UT'   UT   R/                  US	   5        UR/                  US	   5        MM     MV     Me     U(       d9  U(       a2  [0        R2                  " U5      n[        R                  " S
U-   S-   5      e[5        U5      n[        R                  " U5      nUR                  R7                  5         UR                   H}  n[        R                  " U5      nUR                   H&  nUU;   d  M  UR                  R                  U5        M(     UR                  (       d  Mb  UR                  R/                  U5        M     [9        UU
UUS9$ s  snf s  snf ! [:        R<                  [:        R>                  4 a/  n[        R@                  " U[        RB                  5         SnAgSnAf[:        RD                   aN  n[F        RH                  RK                  S5        [        R@                  " U[        RL                  5         SnAgSnAff = f)a  Make API call to disable a specific service.

Args:
  project: The project for which to disable the service.
  services: The list of identifiers of the services to disable, for example
    ['serviceusage.googleapis.com', 'apikeys.googleapis.com'].
  consumer_policy_name: Name of consumer policy. The default name is
    "default".
  force: Disable service with usage within last 30 days or disable recently
    enabled service or disable the service even if there are enabled services
    which depend on it. This also disables the services which depend on the
    service to be disabled.
  folder: The folder for which to disable the service.
  organization: The organization for which to disable the service.
  validate_only: If True, the action will be validated and result will be
    preview but not exceuted.`
  skip_dependency_check: If True, the enabled dependent services of the
    service to be disabled will remian enabled.
  disable_dependency_services: If True, the services which depend on the
    service to be disabled will also be disabled.

Raises:
  exceptions.EnableServiceException: when disabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
c              3   P   >#    U  H  n[         T-  UR                  ;   v   M     g 7fN)r"  r   ).0r   r[   s     r&   	<genexpr>#RemoveEnableRule.<locals>.<genexpr>  s(      
9 ';+?+??9s   #&zThe services r  z( are not enabled in the consumer policy.r   r   r   r   r[   z@The services are depended on by the following active service(s) z . Please remove the active dependent services or provide the --disable-dependency-services flag to disable them, or --bypass-dependency-service-check to ignore this check.)r   r   Nr   )'r  r  r  r   rF   anyr   r   r   r'  r  r  r"  r   remover   r   r   r4   r   r   r   r   r   jsondumpsr!  clearr   r;   r<   r=   r>   r(  r   r
   r   r   r   )r  r   r  r   r  r  r   r>  r?  r.   rA   current_policyr[   services_to_remover   r   	to_remover   r   missing_dependencyr   r   json_stringupdated_consumer_poicyruler*   rE   s               `              r&   RemoveEnableRulerR    s   N $g--$v-M*\9M 8;O OO+Z1,[9N  G 
-99
 
 	    ('G:L+Lx   ""
HHX67  mmN3O&22''w&+*>*>>



%
%&7'&A
B ( 3
 I  1b&&rww0BCb!//<	'	'(4H!"23J?g-"W,8K0LL"4402$W-"7+228I3FG  )!45 . @ 5 )Yjj!34$$NGG
 	
 II!]]?;&&,,.&22]];'d%..,9$
--

|
, / 
**11$7 3 &"	 QL ,,++
 B Az@@AA		0	0 1JJI Az//00	1si   L  (L4L:L   	LLA3L  
B2L   C5L  9.L  +*L  
L   $O%M..OAOOmcp_policy_namec                    [         U -  nU(       a	  [        U-  nU(       a	  [        U-  nU[        U-  -   n [	        U5      nSn[
        R                  " U5      n	U	R                  R                  5         UR                  (       a  UR                   H  n
[
        R                  " U
5      nUR                   H9  nUR                  [        U-  :X  d  M  SnUR                  R                  U5        M;     UR                  (       d  Mu  U	R                  R                  U5        M     U(       a  [        R                  " SU-   S-   5      e[!        X5      $ ! ["        R$                  ["        R&                  4 a/  n[        R(                  " U[        R*                  5         SnAgSnAf["        R,                   a/  n[        R(                  " U[        R.                  5         SnAgSnAff = f)aP  Make API call to disable a service for MCP.

Args:
  project: The project for which to disable the service for MCP.
  service: The service to disable for MCP, for example
    'serviceusage.googleapis.com'.
  mcp_policy_name: Name of MCP policy. The default name is "default".
  folder: The folder for which to disable the service.
  organization: The organization for which to disable the service.

Raises:
  exceptions.EnableMcpServiceException: when disabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
TFr5  z is not enabled for MCP.N)r  r  r  r7  rL   r  r  r8  rJ  r6  r[   r"  rG  r   r   r   r   r;   r<   r=   r>   r;  r   r   )r  r[   rS  r  r  r.   rA   r   already_disabledupdated_mcp_policymcp_enable_rulerQ  r<  rE   s                 r&   RemoveMcpEnableRulerX  V  s   2 $g--$v-M*\9M 3o EE+1+&Fv.%%++-#22/}}_-++K  $5$??$##K0 , 

+
+
2
24
8 3 ""
7
"%?
?  -;;,,++
 E AzCCDD		0	0 1Az//001s1   BE 0E AE $G'7%F!!G'8%G""G'c                 @   [        5       nUR                  nUR                  [        X4-  S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to enable a specific service.

Args:
  project: The project for which to enable the service.
  service: The identifier of the service to enable, for example
    'serviceusage.googleapis.com'.

Raises:
  exceptions.EnableServiceException: when enabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r3   N)r5   r7   !ServiceusageServicesEnableRequest_PROJECT_SERVICE_RESOURCEr   Enabler;   r<   r=   r   r>   r(  r  r[   rB   rC   rD   rE   s         r&   EnableApiCallr^    s     &##(66$'99 7 ;'B??!!'**

0
0

/
/
1 BAz@@AAB   A
 
$B.%BBc                 Z   [        5       nUR                  nUR                  UR                  US9[        U -  S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)aa  Make API call to batch enable services.

Args:
  project: The project for which to enable the services.
  services: Iterable of identifiers of services to enable.

Raises:
  exceptions.EnableServiceException: when enabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
)
serviceIds)batchEnableServicesRequestr   N)r5   r7   &ServiceusageServicesBatchEnableRequestBatchEnableServicesRequestr  r   BatchEnabler;   r<   r=   r   r>   r(  )r  r   rB   rC   rD   rE   s         r&   BatchEnableApiCallrf    s     &##(;;!)!D!D "E "( < *'B??&&w//

0
0

/
/
1 BAz@@AABs   A $B*;%B%%B*c                    [        5       nUR                  nUR                  R                  R                  nU(       a   UR                  R                  R
                  nUR                  [        X4-  UR                  UUS9S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAf[        R                    aN  n["        R$                  R'                  S5        [        R                  " U[        R(                  5         SnAgSnAff = f)a7  Make API call to disable a specific service.

Args:
  project: The project for which to enable the service.
  service: The identifier of the service to disable, for example
    'serviceusage.googleapis.com'.
  force: disable the service even if there are enabled services which depend
    on it. This also disables the services which depend on the service to be
    disabled.

Raises:
  exceptions.EnableServiceException: when disabling API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
)disableDependentServicescheckIfServiceHasUsage)r4   disableServiceRequestNr   )r5   r7   DisableServiceRequest%CheckIfServiceHasUsageValueValuesEnumCHECKSKIP"ServiceusageServicesDisableRequestr[  r   Disabler;   r<   r=   r   r>   r(  r   r
   r   r   r   )r  r[   r   rB   rC   checkrD   rE   s           r&   DisableApiCallrr    s   $ &##(

(
(
N
N
T
T%
**PPUUE77$'99$::#(!& ;  8 '1??""7++

0
0

/
/
1 BAz@@AA		0	0 1JJ ! "Az//001s%   B   $E%C..EAEEc                 @   [        5       nUR                  nUR                  [        X4-  S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a7  Get a service.

Args:
  project: The project for which to get the service.
  service: The service to get.

Raises:
  exceptions.GetServicePermissionDeniedException: when getting service fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The service configuration.
r3   N)r5   r7   r   r[  r   r:   r;   r<   r=   r   r>   #GetServicePermissionDeniedExceptionr]  s         r&   
GetServiceru    s     &##(33$'99 4 ;'O??w''

0
0

/
/
1 OAzMMNNOr_  c                     [        5       nUR                  nU R                  UR                  R                  R
                  :H  $ rB  )r5   r7   stateGoogleApiServiceusageV1ServiceStateValueValuesEnumENABLED)r[   rB   rC   s      r&   IsServiceEnabledr{    s6    &##(	(AAVV^^	^^r%   c                   N    \ rS rSrS r\R                  " \5      SS j5       rSr	g)r   i  c                     Xl         g rB  service_usage)selfr  s     r&   __init___Lister.__init__  s    &r%   Nc                 4    U R                   R                  XS9$ )N)global_params)r  r   )r  rD   r  s      r&   r   _Lister.List   s    ""7"HHr%   r~  rB  )
r   r   r   r   r  r	   RetryOnHttpStatus_TOO_MANY_REQUESTSr   r$   r   r%   r&   r   r     s)    '  23I 4Ir%   r   enabledc                 4   [         U -  nU(       a	  [        U-  nU(       a	  [        U-  n0 n/ n U(       a  U[        -   n	[	        U	5      n
U
R
                   H>  nUR                   H+  nUS:X  a    M  UR                  U SU 35        SX|'   US-  nM-     M@     [        S[        U5      S5       Hk  n[        XhXS-    5      nUR                   HH  nSR                  UR                  R                  S5      SS 5      nUR                  R                  X'   MJ     Mm     Og[!        X#S9 H  nUR                  UUR                  '   M     [#        XbUS9 H0  nUR                  R                  UUR                  R                  '   M2     / n[$        R&                  " S	S
S/5      nU H  nUR                  U" UUU   S95        M     U$ ! [(        R*                  [(        R,                  4 a/  n[.        R0                  " U[.        R2                  5         SnAgSnAff = f)a  Make API call to list services.

Args:
  project: The project for which to list services.
  enabled: List only enabled services.
  page_size: The page size to list.
  limit: The max number of services to display.
  folder: The folder for which to list services.
  organization: The organization for which to list services.

Raises:
  exceptions.ListServicesException: when listing services
  fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The list of services
r   r    r      r   N)r   r   ServiceListr4   title)r4   r  )r  r  r  _EFFECTIVE_POLICYrx   r   r   r   rangelenr   r'  r4   r%  r[   displayName_ListPublicServices_ListSharedServicescollections
namedtupler;   r<   r=   r   r>   ListServicesException)r  r  r   r   r  r  r.   r   r   rA   effectivepolicyrulesvaluer   service_stater*   public_serviceshared_serviceresultservice_infor[   rE   s                         r&   ListServicesV2Betar  %  s   4 $g--$v-M*\9M(&)A!$55k0=o"..%^^EaZ
--=/5'2
3(/
1*% $ / CK,%"=2LM%..M-"4"4":":3"?"CD,#0#8#8#D#D(
  / - 0. )7(B(B$$% 0
E. "".. 	'',,- F))-&'9JKLmmLgXg5FGH  M,,++
 A Az??@@	As   FG $H(%HHc                    [         U -  nU(       a	  [        U-  nU(       a	  [        U-  n0 n/ n U(       GaJ  U[        -   n	[	        U	5      n
U
R
                   HD  nUR                   H1  nUR                  U SUR                   35        SX|R                  '   M3     MF     [        S[        U5      S5       H  n[        XhXS-    5      nUR                   H  nUS:X  a    M+  SR                  UR                  R                  S5      SS 5      nUR                  R                   (       aK  UR                  R                   R"                  (       a&  UR                  R                   R"                  S   UU'   US-  nM     M     O>[%        U[&        U5       H)  nUR                   R"                  S   UUR                  '   M+     / n[(        R*                  " SS	S
/5      nU H  nUR                  U" UUU   S95        M     U$ ! [,        R.                  [,        R0                  4 a/  n[2        R4                  " U[2        R6                  5         SnAgSnAff = f)a  Make API call to list services.

Args:
  project: The project for which to list MCP services.
  enabled: List only enabled  MCP services.
  page_size: The page size to list.
  limit: The max number of services to display.
  folder: The folder for which to list MCP services.
  organization: The organization for which to list MCP services.

Raises:
  exceptions.ListMcpServicesException: when listing MCP services
  fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The list of MCP services
r   r  r   r  r   Nr   r  r4   mcp_endpoint)r4   r  )r  r  r  _EFFECTIVE_MCP_POLICYr~   r8  r6  r   r[   r  r  r   r   r'  r4   r%  	mcpServerurlsr  _MCP_LIST_FILTERr  r  r;   r<   r=   r   r>   ListMcpServicesException)r  r  r   r   r  r  r.   service_to_endpointr   rA   effectivemcppolicyr  r<  r  r   r  r*   r  r  r  r[   rE   s                         r&   ListMcpServicesV2Betar  t  s2   6 $g--$v-M*\9M&/D!$99k0=%44% ,,K
--=/;+>+>*?@
A57
11
2 - 5
 CK,%"=2LM%..MaZ-"4"4":":3"?"CD, ##--''1166 %%//44Q7  - 1*% / -" 0
%u. $$))!, 	N//0 F))/L 'mm
G2Eg2N
O '
 M,,++
 D AzBBCC	Ds   GG> >$I"%IIc           	      z   [        5       nUR                  nU(       a  SnOSnUR                  U[        U -  S9n [        R
                  " [        UR                  5      UUSUSS9$ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to list services.

Args:
  project: The project for which to list services.
  enabled: List only enabled services.
  page_size: The page size to list.
  limit: The max number of services to display.

Raises:
  exceptions.ListServicesException: when listing services
  fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The list of services
zstate:ENABLEDN)filterr   r   r   r   )r5   r7   ServiceusageServicesListRequestr  r   r   r   r   r;   r<   r=   r   r>   r  )	r  r  r   r   rB   rC   service_filterrD   rE   s	            r&   ListServicesr    s    " &##($NN44$5$? 5 A'
A## '  
0
0

/
/
1 AAz??@@As   +A' '$B:%B55B:c                 0   [        5       nUR                  nUR                  U S9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a.  Make API call to get an operation using serviceusageV1 api.

Args:
  name: The name of operation.

Raises:
  exceptions.OperationErrorException: when the getting operation API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
r3   Nr5   r7    ServiceusageOperationsGetRequest
operationsr:   r;   r<   r=   r   r>   OperationErrorExceptionrR   s        r&   GetOperationr    s     &##(5545@'C  ))

0
0

/
/
1 CAzAABBCs   A $B&%BBc                 2   [        S5      nUR                  nUR                  U S9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get an operation using serviceusageV2alpha api.

Args:
  name: The name of the operation resource. Format
    'operations/<operation_id>'.

Raises:
  exceptions.OperationErrorException: when the getting operation API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The message.Operation object with response and error.
r   r3   Nr  rR   s        r&   GetOperationV2Alphar    s     i(&##(5545@'C  )),,++
 C AzAABB	Cs   A $B'%BBc                 6   [        [        S9nUR                  nUR                  U S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get an operation using serviceusageV2beta api.

Args:
  name: The name of the operation resource. Format
    'operations/<operation_id>'.

Raises:
  exceptions.OperationErrorException: when the getting operation API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The message.Operation object with response and error.
r1   r3   N)r5   r6   r7   r  r  r:   r;   r<   r=   r   r>   r  rR   s        r&   r   r   "  s     o6&##(5545@'C  )),,++
 C AzAABB	CrG   enabled_servicesc                    [        [        S9nUR                  n[        [	        U5      5       H4  nUR                  SU  SU 3S9n UR                  R                  U5      nM6     g! [        R                   a     MP  [        R                  [        R                  4 a0  n[        R                  " U[        R                  5         SnAM  SnAff = f)a1  Generate a service identity for an enabled service.

Args:
  container: The container to generate a service identity for.
  enabled_services: The services to generate a service identity for.

Raises:
  exceptions.GenerateServiceIdentityPermissionDeniedException: when
  generating
  service identity fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the
  service.

Returns:
  A dict with the email and uniqueId of the generated service identity. If
  service does not have a default identity, the response will be an empty
  dictionary.
r1   r   r   r   N)r5   _V1BETA1_VERSIONr7   sortedr&  2ServiceusageServicesGenerateServiceIdentityRequestr   GenerateServiceIdentityr;   r   r<   r=   r   r>   0GenerateServiceIdentityPermissionDeniedException)	containerr  rB   rC   r[   rD   _rE   s           r&   (GenerateServiceIdentityForEnabledServicer  <  s    * &67&##( -./gII9+Qwi0 J G
//
1
1'
:a 0 22  ..--  
ZHH 	s   A''C>#C!%CCc                    [        [        S9nUR                  nU[        R                  :X  a  [
        X4-  nOIU[        R                  :X  a  [        X4-  nO*U[        R                  :X  a  [        X4-  nO[        S5      eUR                  US9n UR                  R                  U5      n[        R                  " UR                   5      nS V	s0 s H  oU;   d  M
  XU	   _M     sn	$ s  sn	f ! ["        R$                  ["        R&                  4 a/  n
[(        R*                  " U
[(        R,                  5         Sn
A
gSn
A
ff = f)aL  Generate a service identity.

Args:
  container: The container to generate a service identity for.
  service: The service to generate a service identity for.
  container_type: The type of container, default to be project.

Raises:
  exceptions.GenerateServiceIdentityPermissionDeniedException: when generating
  service identity fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  A dict with the email and uniqueId of the generated service identity. If
  service does not have a default identity, the response will be an empty
  dictionary.
r1   z!Invalid container type specified.r   )emailuniqueIdN)r5   r  r7   r   r!   r[  r"   _FOLDER_SERVICE_RESOURCEr#   _ORG_SERVICE_RESOURCE
ValueErrorr  r   r  r   r   r   r;   r<   r=   r   r>   r  )r  r[   container_typerB   rC   r   rD   r   r   krE   s              r&   r  r  h  s,   ( &67&##(}===&))==F>>>%(<<F;;;"i%99F
8
99GG H '
H		0	0	9B%%bkk2H %:K$9q(]NA{N$9KKK

0
0

/
/
1 H	:FFH HHs0   ?C/ 	C*	C*'C/ *C/ /$E%D==Ec           	          [        U 5        [        [        S9nUR                  nUR	                  [
        X4-  S9n[        R                  " UR                  UUSUSS9$ )a  List service quota metrics for a consumer.

Args:
  consumer: The consumer to list metrics for, e.g. "projects/123".
  service: The service to list metrics for.
  page_size: The page size to list.
  limit: The max number of metrics to return.

Raises:
  exceptions.PermissionDeniedException: when listing metrics fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The list of quota metrics
r1   r   r   metricsr   )	_ValidateConsumerr5   r  r7   3ServiceusageServicesConsumerQuotaMetricsListRequest_CONSUMER_SERVICE_RESOURCEr   r   services_consumerQuotaMetrics)consumerr[   r   r   rB   rC   rD   s          r&   ListQuotaMetricsr    sn      H&67&##(HH'8*== I ?'		!	!**%
 r%   c                    [        U 5        [        [        S9nUR                  n[	        X5      n	UR                  [        X4-  UR                  UR                  UR                  UUUU	S9/S9US9S9n
 UR                  R                  U
5      $ ! [        R                  [        R                  4 a/  n[        R                   " U[        R"                  5         SnAgSnAff = f)a  Update a quota override.

Args:
  consumer: The consumer to update a quota override for, e.g. "projects/123".
  service: The service to update a quota override for.
  metric: The quota metric name.
  unit: The unit of quota metric.
  dimensions: The dimensions of the override in dictionary format. It can be
    None.
  value: The override integer value.
  force: Force override update even if the change results in a substantial
    decrease in available quota.

Raises:
  exceptions.UpdateQuotaOverridePermissionDeniedException: when updating an
  override fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The quota override operation.
r1   )metricunitoverrideValue
dimensions)	overrides)inlineSourcer   )r   importConsumerOverridesRequestN)r  r5   r  r7   _GetDimensionsFServiceusageServicesConsumerQuotaMetricsImportConsumerOverridesRequestr  ImportConsumerOverridesRequestOverrideInlineSourceQuotaOverrider  ImportConsumerOverridesr;   r<   r=   r   r>   ,UpdateQuotaOverridePermissionDeniedException)r  r[   r  r  r  r  r   rB   rC   dimensions_messagerD   rE   s               r&   UpdateQuotaOverrideCallr    s   8 H&67&##(%h;[['8*==%-%L%L44((#$)!3	 ) 5 5   &M 	& \ 'D//GGPP

0
0

/
/
1 D	:BBD DDs   5B $C#4%CC#c                 z   [        U 5        [        [        S9nUR                  n[	        XX#5      n[
        X4-  n	UR                  U	US9n
 UR                  R                  U
5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)aW  Delete a quota override.

Args:
  consumer: The consumer to delete a quota override for, e.g. "projects/123".
  service: The service to delete a quota aoverride for.
  metric: The quota metric name.
  unit: The unit of quota metric.
  override_id: The override ID.
  force: Force override deletion even if the change results in a substantial
    decrease in available quota.

Raises:
  exceptions.DeleteQuotaOverridePermissionDeniedException: when deleting an
  override fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The quota override operation.
r1   )r4   r   N)r  r5   r  r7   _GetMetricResourceName_LIMIT_OVERRIDE_RESOURCELServiceusageServicesConsumerQuotaMetricsLimitsConsumerOverridesDeleteRequest6services_consumerQuotaMetrics_limits_consumerOverridesDeleter;   r<   r=   r   r>   ,DeleteQuotaOverridePermissionDeniedException)r  r[   r  r  override_idr   rB   rC   r   r4   rD   rE   s               r&   DeleteQuotaOverrideCallr    s    2 H&67&##(!(VB&	!V$9	9$aa b 'DHHOO 

0
0

/
/
1 D	:BBD DDs   A' '$B:%B55B:c           
          Uc  g U R                   R                  nU" [        UR                  5       5       Vs/ s H  nUR	                  X1U   S9PM     snS9$ s  snf )N)keyr  )additionalProperties)r  DimensionsValuer  r   AdditionalProperty)rC   r  dtr  s       r&   r  r    si    --"	 *//+,,a 

A]

;,

 
s   Ac                     [        X5      nU HH  nUR                  U:X  d  M  UR                   H#  nUR                  U:X  d  M  UR                  s  s  $    MJ     [
        R                  " SU< SU< S35      e)a|  Get the metric resource name from metric name and unit.

Args:
  consumer: The consumer to manage an override for, e.g. "projects/123".
  service: The service to manage an override for.
  metric: The quota metric name.
  unit: The unit of quota metric.

Raises:
  exceptions.Error: when the limit with given metric and unit is not found.

Returns:
  The quota override operation.
zlimit not found with name "z" and unit "z".)r  r  consumerQuotaLimitsr  r4   r   r   )r  r[   r  r  r  mqs          r&   r  r  $  sg     X/'axx6$$!66T>- % 
 	 $( 	) )r%   c                 ~    [          H  nU R                  U5      (       d  M    g    [        R                  " SU -  5      e)Nzinvalid consumer format "%s".)_VALID_CONSUMER_PREFIXr  r   r   )r  prefixs     r&   r  r  =  s9    &f6"" ' 	88CDDr%   i  r  c           	      X   [        [        S9nUR                  nUR                  US9n [        R
                  " [        UR                  5      UUSU SS9$ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to list public services.

Args:
  page_size: The page size to list. default=1000
  list_filter: The filter to list public services.
  limit: The max number of services to display.

Raises:
  exceptions.ListPublicServicesException: when listing public services fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.ListPublicServicesResponse: The public services.
r1   )r  r   r   r   N)r5   r6   r7   r  r   r   r   r   r;   r<   r=   r   r>   ListPublicServicesException)r   list_filterr   rB   rC   rD   rE   s          r&   r  r  D  s     o6&##(44K4H'G## '  ,,++
 G AzEEFF	G   +A $B):%B$$B)c           	      X   [        [        S9nUR                  nUR                  XS9n [        R
                  " [        UR                  5      UUSUSS9$ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to list shared services.

Args:
  parent: The parent for which to list shared services.
  page_size: The page size to list. default=1000
  list_filter: The filter to list shared services.
  limit: The max number of services to display.

Raises:
  exceptions.ListSharedServicesException: when listing shared services fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  Message.ListSharedServicesResponse: The shared services.
r1   )r   r  r   sharedServicesr   N)r5   r6   r7   %ServiceusageSharedServicesListRequestr   r   r   r  r;   r<   r=   r   r>   ListSharedServicesException)r   r   r  r   rB   rC   rD   rE   s           r&   r  r  h  s    $ o6&##(:: ; 'G##%%&'  ,,++
 G AzEEFF	Gr  c                     SSK Jn  [        R                  R                  R
                  R                  5       nUR                  [        R                  US9n[        R                  " SXS9$ )z(Get a client instance for service usage.r   )
transports)response_encodingenable_resource_quotaserviceusage)http_client)googlecloudsdk.core.credentialsr  r   VALUESbillingquota_projectIsExplicitlySetGetApitoolsTransportr   ENCODINGr   r5   )r2   r  r  r  s       r&   r5   r5     sg     9 --==? //!**1 0 3+ 
	)	)g
8 8r%   )rn   )FF)r   )FFF)r4  NNFF)NN)r4  FNNFFF)r4  NN)F)r   )kr    r  r  enumrH  systypingr   apitools.base.pyr   r   r;   r   googlecloudsdk.api_lib.servicesr   googlecloudsdk.api_lib.utilr   r	   googlecloudsdk.corer
   r   r   r  r  r  r[  r  r  r"  r$  _REVERSE_CLOSUREr  r   r7  r  r  r  _GOOGLE_CATEGORY_RESOURCEr  	frozensetr  _V1_VERSIONr  _V1ALPHA_VERSION_V2ALPHA_VERSIONr6   r  r(   Enumr   r+   r/   rF   rL   rS   rZ   r   rb   rj   rx   r~   r   r   maxsizer   r   r   r   intr   r   r   r   r   boolr   r  r  r2  r=  rR  rX  r^  rf  rr  ru  r{  r   r  r  r  r  r  r   r&  r  r!   r  r  r  r  r  r  r  r  r  r5   r   r%   r&   <module>r     s   !     
  % > ' 6 9 5 2 # * )!  + 5 3 6 ! * $ - 1 ' $ & - / 4 "#NO     
  1 DII /
F<A<M<PB#C #Cs #CL @c  @C  @F&G3 &Gc &GR'J 'J3 'JT?@ DF 8;#++ 'IV 5:,1^"DL 5:,1d 	3G3G3G 3G 	3Gn 9;'K'K"%'K25'KT-J# -Jc -Jc -J`& &s &s &R#JP  $)	VIVI "VI 	VIr7O"7O7Ot;";;B !*!sB3isBsB sB 	sB
 sB sB sBr 	>E>E>E >E 	>EH !*"'(-K1K13iK1 K1 	K1
 K1 K1 K1  K1 "&K1b %A1A1A1 A1 	A1
 A1HB6B8'1TO4_I I LALALA LA 	LA
 LA LAh SDSDSD SD 	SD
 SD SDl$ANCs C.Cc C4CS C4)!%c)Z (5'M'M,H^J #(3Dv #()DX	
)2E #'Bckk !GJ #++&GR8r%   