"""Generated client library for firebaserules version v1."""
# NOTE: This file is autogenerated and should not be edited by hand.

from apitools.base.py import base_api
from googlecloudsdk.generated_clients.apis.firebaserules.v1 import firebaserules_v1_messages as messages


class FirebaserulesV1(base_api.BaseApiClient):
  """Generated client library for service firebaserules version v1."""

  MESSAGES_MODULE = messages
  BASE_URL = 'https://firebaserules.googleapis.com/'
  MTLS_BASE_URL = 'https://firebaserules.mtls.googleapis.com/'

  _PACKAGE = 'firebaserules'
  _SCOPES = ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/firebase', 'https://www.googleapis.com/auth/firebase.readonly']
  _VERSION = 'v1'
  _CLIENT_ID = 'CLIENT_ID'
  _CLIENT_SECRET = 'CLIENT_SECRET'
  _USER_AGENT = 'google-cloud-sdk'
  _CLIENT_CLASS_NAME = 'FirebaserulesV1'
  _URL_VERSION = 'v1'
  _API_KEY = None

  def __init__(self, url='', credentials=None,
               get_credentials=True, http=None, model=None,
               log_request=False, log_response=False,
               credentials_args=None, default_global_params=None,
               additional_http_headers=None, response_encoding=None):
    """Create a new firebaserules handle."""
    url = url or self.BASE_URL
    super(FirebaserulesV1, self).__init__(
        url, credentials=credentials,
        get_credentials=get_credentials, http=http, model=model,
        log_request=log_request, log_response=log_response,
        credentials_args=credentials_args,
        default_global_params=default_global_params,
        additional_http_headers=additional_http_headers,
        response_encoding=response_encoding)
    self.projects_releases = self.ProjectsReleasesService(self)
    self.projects_rulesets = self.ProjectsRulesetsService(self)
    self.projects = self.ProjectsService(self)

  class ProjectsReleasesService(base_api.BaseApiService):
    """Service class for the projects_releases resource."""

    _NAME = 'projects_releases'

    def __init__(self, client):
      super(FirebaserulesV1.ProjectsReleasesService, self).__init__(client)
      self._upload_configs = {
          }

    def Create(self, request, global_params=None):
      r"""Create a `Release`. Release names should reflect the developer's deployment practices. For example, the release name may include the environment name, application name, application version, or any other name meaningful to the developer. Once a `Release` refers to a `Ruleset`, the rules can be enforced by Firebase Rules-enabled services. More than one `Release` may be 'live' concurrently. Consider the following three `Release` names for `projects/foo` and the `Ruleset` to which they refer. Release Name -> Ruleset Name * projects/foo/releases/prod -> projects/foo/rulesets/uuid123 * projects/foo/releases/prod/beta -> projects/foo/rulesets/uuid123 * projects/foo/releases/prod/v23 -> projects/foo/rulesets/uuid456 The relationships reflect a `Ruleset` rollout in progress. The `prod` and `prod/beta` releases refer to the same `Ruleset`. However, `prod/v23` refers to a new `Ruleset`. The `Ruleset` reference for a `Release` may be updated using the UpdateRelease method.

      Args:
        request: (Release) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Release) The response message.
      """
      config = self.GetMethodConfig('Create')
      return self._RunMethod(
          config, request, global_params=global_params)

    Create.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/releases',
        http_method='POST',
        method_id='firebaserules.projects.releases.create',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}/releases',
        request_field='<request>',
        request_type_name='Release',
        response_type_name='Release',
        supports_download=False,
    )

    def Delete(self, request, global_params=None):
      r"""Delete a `Release` by resource name.

      Args:
        request: (FirebaserulesProjectsReleasesDeleteRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Empty) The response message.
      """
      config = self.GetMethodConfig('Delete')
      return self._RunMethod(
          config, request, global_params=global_params)

    Delete.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/releases/{releasesId}',
        http_method='DELETE',
        method_id='firebaserules.projects.releases.delete',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}',
        request_field='',
        request_type_name='FirebaserulesProjectsReleasesDeleteRequest',
        response_type_name='Empty',
        supports_download=False,
    )

    def Get(self, request, global_params=None):
      r"""Get a `Release` by name.

      Args:
        request: (FirebaserulesProjectsReleasesGetRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Release) The response message.
      """
      config = self.GetMethodConfig('Get')
      return self._RunMethod(
          config, request, global_params=global_params)

    Get.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/releases/{releasesId}',
        http_method='GET',
        method_id='firebaserules.projects.releases.get',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}',
        request_field='',
        request_type_name='FirebaserulesProjectsReleasesGetRequest',
        response_type_name='Release',
        supports_download=False,
    )

    def GetExecutable(self, request, global_params=None):
      r"""Get the `Release` executable to use when enforcing rules.

      Args:
        request: (FirebaserulesProjectsReleasesGetExecutableRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (GetReleaseExecutableResponse) The response message.
      """
      config = self.GetMethodConfig('GetExecutable')
      return self._RunMethod(
          config, request, global_params=global_params)

    GetExecutable.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/releases/{releasesId}:getExecutable',
        http_method='GET',
        method_id='firebaserules.projects.releases.getExecutable',
        ordered_params=['name'],
        path_params=['name'],
        query_params=['executableVersion'],
        relative_path='v1/{+name}:getExecutable',
        request_field='',
        request_type_name='FirebaserulesProjectsReleasesGetExecutableRequest',
        response_type_name='GetReleaseExecutableResponse',
        supports_download=False,
    )

    def List(self, request, global_params=None):
      r"""List the `Release` values for a project. This list may optionally be filtered by `Release` name, `Ruleset` name, `TestSuite` name, or any combination thereof.

      Args:
        request: (FirebaserulesProjectsReleasesListRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (ListReleasesResponse) The response message.
      """
      config = self.GetMethodConfig('List')
      return self._RunMethod(
          config, request, global_params=global_params)

    List.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/releases',
        http_method='GET',
        method_id='firebaserules.projects.releases.list',
        ordered_params=['name'],
        path_params=['name'],
        query_params=['filter', 'pageSize', 'pageToken'],
        relative_path='v1/{+name}/releases',
        request_field='',
        request_type_name='FirebaserulesProjectsReleasesListRequest',
        response_type_name='ListReleasesResponse',
        supports_download=False,
    )

    def Patch(self, request, global_params=None):
      r"""Update a `Release` via PATCH. Only updates to `ruleset_name` will be honored. `Release` rename is not supported. To create a `Release` use the CreateRelease method.

      Args:
        request: (FirebaserulesProjectsReleasesPatchRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Release) The response message.
      """
      config = self.GetMethodConfig('Patch')
      return self._RunMethod(
          config, request, global_params=global_params)

    Patch.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/releases/{releasesId}',
        http_method='PATCH',
        method_id='firebaserules.projects.releases.patch',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}',
        request_field='updateReleaseRequest',
        request_type_name='FirebaserulesProjectsReleasesPatchRequest',
        response_type_name='Release',
        supports_download=False,
    )

  class ProjectsRulesetsService(base_api.BaseApiService):
    """Service class for the projects_rulesets resource."""

    _NAME = 'projects_rulesets'

    def __init__(self, client):
      super(FirebaserulesV1.ProjectsRulesetsService, self).__init__(client)
      self._upload_configs = {
          }

    def Create(self, request, global_params=None):
      r"""Create a `Ruleset` from `Source`. The `Ruleset` is given a unique generated name which is returned to the caller. `Source` containing syntactic or semantics errors will result in an error response indicating the first error encountered. For a detailed view of `Source` issues, use TestRuleset.

      Args:
        request: (Ruleset) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Ruleset) The response message.
      """
      config = self.GetMethodConfig('Create')
      return self._RunMethod(
          config, request, global_params=global_params)

    Create.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/rulesets',
        http_method='POST',
        method_id='firebaserules.projects.rulesets.create',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}/rulesets',
        request_field='<request>',
        request_type_name='Ruleset',
        response_type_name='Ruleset',
        supports_download=False,
    )

    def Delete(self, request, global_params=None):
      r"""Delete a `Ruleset` by resource name. If the `Ruleset` is referenced by a `Release` the operation will fail.

      Args:
        request: (FirebaserulesProjectsRulesetsDeleteRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Empty) The response message.
      """
      config = self.GetMethodConfig('Delete')
      return self._RunMethod(
          config, request, global_params=global_params)

    Delete.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/rulesets/{rulesetsId}',
        http_method='DELETE',
        method_id='firebaserules.projects.rulesets.delete',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}',
        request_field='',
        request_type_name='FirebaserulesProjectsRulesetsDeleteRequest',
        response_type_name='Empty',
        supports_download=False,
    )

    def Get(self, request, global_params=None):
      r"""Get a `Ruleset` by name including the full `Source` contents.

      Args:
        request: (FirebaserulesProjectsRulesetsGetRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (Ruleset) The response message.
      """
      config = self.GetMethodConfig('Get')
      return self._RunMethod(
          config, request, global_params=global_params)

    Get.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/rulesets/{rulesetsId}',
        http_method='GET',
        method_id='firebaserules.projects.rulesets.get',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}',
        request_field='',
        request_type_name='FirebaserulesProjectsRulesetsGetRequest',
        response_type_name='Ruleset',
        supports_download=False,
    )

    def List(self, request, global_params=None):
      r"""List `Ruleset` metadata only and optionally filter the results by `Ruleset` name. The full `Source` contents of a `Ruleset` may be retrieved with GetRuleset.

      Args:
        request: (FirebaserulesProjectsRulesetsListRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (ListRulesetsResponse) The response message.
      """
      config = self.GetMethodConfig('List')
      return self._RunMethod(
          config, request, global_params=global_params)

    List.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}/rulesets',
        http_method='GET',
        method_id='firebaserules.projects.rulesets.list',
        ordered_params=['name'],
        path_params=['name'],
        query_params=['filter', 'pageSize', 'pageToken'],
        relative_path='v1/{+name}/rulesets',
        request_field='',
        request_type_name='FirebaserulesProjectsRulesetsListRequest',
        response_type_name='ListRulesetsResponse',
        supports_download=False,
    )

  class ProjectsService(base_api.BaseApiService):
    """Service class for the projects resource."""

    _NAME = 'projects'

    def __init__(self, client):
      super(FirebaserulesV1.ProjectsService, self).__init__(client)
      self._upload_configs = {
          }

    def Test(self, request, global_params=None):
      r"""Test `Source` for syntactic and semantic correctness. Issues present, if any, will be returned to the caller with a description, severity, and source location. The test method may be executed with `Source` or a `Ruleset` name. Passing `Source` is useful for unit testing new rules. Passing a `Ruleset` name is useful for regression testing an existing rule. The following is an example of `Source` that permits users to upload images to a bucket bearing their user id and matching the correct metadata: _*Example*_ // Users are allowed to subscribe and unsubscribe to the blog. service firebase.storage { match /users/{userId}/images/{imageName} { allow write: if userId == request.auth.uid && (imageName.matches('*.png$') || imageName.matches('*.jpg$')) && resource.mimeType.matches('^image/') } }.

      Args:
        request: (FirebaserulesProjectsTestRequest) input message
        global_params: (StandardQueryParameters, default: None) global arguments
      Returns:
        (TestRulesetResponse) The response message.
      """
      config = self.GetMethodConfig('Test')
      return self._RunMethod(
          config, request, global_params=global_params)

    Test.method_config = lambda: base_api.ApiMethodInfo(
        flat_path='v1/projects/{projectsId}:test',
        http_method='POST',
        method_id='firebaserules.projects.test',
        ordered_params=['name'],
        path_params=['name'],
        query_params=[],
        relative_path='v1/{+name}:test',
        request_field='testRulesetRequest',
        request_type_name='FirebaserulesProjectsTestRequest',
        response_type_name='TestRulesetResponse',
        supports_download=False,
    )
