# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc

from google.cloud.resourcemanager.v2 import folders_pb2 as google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2
from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2
from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2
from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2


class FoldersStub(object):
  """Manages Cloud Resource Folders.
  Cloud Resource Folders can be used to organize the resources under an
  organization and to control the IAM policies applied to groups of resources.
  """

  def __init__(self, channel):
    """Constructor.

    Args:
      channel: A grpc.Channel.
    """
    self.ListFolders = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/ListFolders',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.ListFoldersRequest.SerializeToString,
        response_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.ListFoldersResponse.FromString,
        )
    self.SearchFolders = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/SearchFolders',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.SearchFoldersRequest.SerializeToString,
        response_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.SearchFoldersResponse.FromString,
        )
    self.GetFolder = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/GetFolder',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.GetFolderRequest.SerializeToString,
        response_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.FromString,
        )
    self.CreateFolder = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/CreateFolder',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.CreateFolderRequest.SerializeToString,
        response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString,
        )
    self.UpdateFolder = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/UpdateFolder',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.UpdateFolderRequest.SerializeToString,
        response_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.FromString,
        )
    self.MoveFolder = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/MoveFolder',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.MoveFolderRequest.SerializeToString,
        response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString,
        )
    self.DeleteFolder = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/DeleteFolder',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.DeleteFolderRequest.SerializeToString,
        response_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.FromString,
        )
    self.UndeleteFolder = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/UndeleteFolder',
        request_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.UndeleteFolderRequest.SerializeToString,
        response_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.FromString,
        )
    self.GetIamPolicy = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/GetIamPolicy',
        request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString,
        response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString,
        )
    self.SetIamPolicy = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/SetIamPolicy',
        request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString,
        response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString,
        )
    self.TestIamPermissions = channel.unary_unary(
        '/google.cloud.resourcemanager.v2.Folders/TestIamPermissions',
        request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString,
        response_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString,
        )


class FoldersServicer(object):
  """Manages Cloud Resource Folders.
  Cloud Resource Folders can be used to organize the resources under an
  organization and to control the IAM policies applied to groups of resources.
  """

  def ListFolders(self, request, context):
    """Lists the Folders that are direct descendants of supplied parent resource.
    List provides a strongly consistent view of the Folders underneath
    the specified parent resource.
    List returns Folders sorted based upon the (ascending) lexical ordering
    of their display_name.
    The caller must have `resourcemanager.folders.list` permission on the
    identified parent.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def SearchFolders(self, request, context):
    """Search for folders that match specific filter criteria.
    Search provides an eventually consistent view of the folders a user has
    access to which meet the specified filter criteria.

    This will only return folders on which the caller has the
    permission `resourcemanager.folders.get`.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def GetFolder(self, request, context):
    """Retrieves a Folder identified by the supplied resource name.
    Valid Folder resource names have the format `folders/{folder_id}`
    (for example, `folders/1234`).
    The caller must have `resourcemanager.folders.get` permission on the
    identified folder.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def CreateFolder(self, request, context):
    """Creates a Folder in the resource hierarchy.
    Returns an Operation which can be used to track the progress of the
    folder creation workflow.
    Upon success the Operation.response field will be populated with the
    created Folder.

    In order to succeed, the addition of this new Folder must not violate
    the Folder naming, height or fanout constraints.

    + The Folder's display_name must be distinct from all other Folder's that
    share its parent.
    + The addition of the Folder must not cause the active Folder hierarchy
    to exceed a height of 4. Note, the full active + deleted Folder hierarchy
    is allowed to reach a height of 8; this provides additional headroom when
    moving folders that contain deleted folders.
    + The addition of the Folder must not cause the total number of Folders
    under its parent to exceed 100.

    If the operation fails due to a folder constraint violation, some errors
    may be returned by the CreateFolder request, with status code
    FAILED_PRECONDITION and an error description. Other folder constraint
    violations will be communicated in the Operation, with the specific
    PreconditionFailure returned via the details list in the Operation.error
    field.

    The caller must have `resourcemanager.folders.create` permission on the
    identified parent.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def UpdateFolder(self, request, context):
    """Updates a Folder, changing its display_name.
    Changes to the folder display_name will be rejected if they violate either
    the display_name formatting rules or naming constraints described in
    the [CreateFolder][google.cloud.resourcemanager.v2.Folders.CreateFolder] documentation.

    The Folder's display name must start and end with a letter or digit,
    may contain letters, digits, spaces, hyphens and underscores and can be
    no longer than 30 characters. This is captured by the regular expression:
    [\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.
    The caller must have `resourcemanager.folders.update` permission on the
    identified folder.

    If the update fails due to the unique name constraint then a
    PreconditionFailure explaining this violation will be returned
    in the Status.details field.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def MoveFolder(self, request, context):
    """Moves a Folder under a new resource parent.
    Returns an Operation which can be used to track the progress of the
    folder move workflow.
    Upon success the Operation.response field will be populated with the
    moved Folder.
    Upon failure, a FolderOperationError categorizing the failure cause will
    be returned - if the failure occurs synchronously then the
    FolderOperationError will be returned via the Status.details field
    and if it occurs asynchronously then the FolderOperation will be returned
    via the Operation.error field.
    In addition, the Operation.metadata field will be populated with a
    FolderOperation message as an aid to stateless clients.
    Folder moves will be rejected if they violate either the naming, height
    or fanout constraints described in the
    [CreateFolder][google.cloud.resourcemanager.v2.Folders.CreateFolder] documentation.
    The caller must have `resourcemanager.folders.move` permission on the
    folder's current and proposed new parent.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def DeleteFolder(self, request, context):
    """Requests deletion of a Folder. The Folder is moved into the
    [DELETE_REQUESTED][google.cloud.resourcemanager.v2.Folder.LifecycleState.DELETE_REQUESTED] state
    immediately, and is deleted approximately 30 days later. This method may
    only be called on an empty Folder in the
    [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE] state, where a Folder is empty if
    it doesn't contain any Folders or Projects in the
    [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE] state.
    The caller must have `resourcemanager.folders.delete` permission on the
    identified folder.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def UndeleteFolder(self, request, context):
    """Cancels the deletion request for a Folder. This method may only be
    called on a Folder in the
    [DELETE_REQUESTED][google.cloud.resourcemanager.v2.Folder.LifecycleState.DELETE_REQUESTED] state.
    In order to succeed, the Folder's parent must be in the
    [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE] state.
    In addition, reintroducing the folder into the tree must not violate
    folder naming, height and fanout constraints described in the
    [CreateFolder][google.cloud.resourcemanager.v2.Folders.CreateFolder] documentation.
    The caller must have `resourcemanager.folders.undelete` permission on the
    identified folder.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def GetIamPolicy(self, request, context):
    """Gets the access control policy for a Folder. The returned policy may be
    empty if no such policy or resource exists. The `resource` field should
    be the Folder's resource name, e.g. "folders/1234".
    The caller must have `resourcemanager.folders.getIamPolicy` permission
    on the identified folder.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def SetIamPolicy(self, request, context):
    """Sets the access control policy on a Folder, replacing any existing policy.
    The `resource` field should be the Folder's resource name, e.g.
    "folders/1234".
    The caller must have `resourcemanager.folders.setIamPolicy` permission
    on the identified folder.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def TestIamPermissions(self, request, context):
    """Returns permissions that a caller has on the specified Folder.
    The `resource` field should be the Folder's resource name,
    e.g. "folders/1234".

    There are no permissions required for making this API call.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')


def add_FoldersServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'ListFolders': grpc.unary_unary_rpc_method_handler(
          servicer.ListFolders,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.ListFoldersRequest.FromString,
          response_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.ListFoldersResponse.SerializeToString,
      ),
      'SearchFolders': grpc.unary_unary_rpc_method_handler(
          servicer.SearchFolders,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.SearchFoldersRequest.FromString,
          response_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.SearchFoldersResponse.SerializeToString,
      ),
      'GetFolder': grpc.unary_unary_rpc_method_handler(
          servicer.GetFolder,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.GetFolderRequest.FromString,
          response_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.SerializeToString,
      ),
      'CreateFolder': grpc.unary_unary_rpc_method_handler(
          servicer.CreateFolder,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.CreateFolderRequest.FromString,
          response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
      ),
      'UpdateFolder': grpc.unary_unary_rpc_method_handler(
          servicer.UpdateFolder,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.UpdateFolderRequest.FromString,
          response_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.SerializeToString,
      ),
      'MoveFolder': grpc.unary_unary_rpc_method_handler(
          servicer.MoveFolder,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.MoveFolderRequest.FromString,
          response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
      ),
      'DeleteFolder': grpc.unary_unary_rpc_method_handler(
          servicer.DeleteFolder,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.DeleteFolderRequest.FromString,
          response_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.SerializeToString,
      ),
      'UndeleteFolder': grpc.unary_unary_rpc_method_handler(
          servicer.UndeleteFolder,
          request_deserializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.UndeleteFolderRequest.FromString,
          response_serializer=google_dot_cloud_dot_resourcemanager_dot_v2_dot_folders__pb2.Folder.SerializeToString,
      ),
      'GetIamPolicy': grpc.unary_unary_rpc_method_handler(
          servicer.GetIamPolicy,
          request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString,
          response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString,
      ),
      'SetIamPolicy': grpc.unary_unary_rpc_method_handler(
          servicer.SetIamPolicy,
          request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString,
          response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString,
      ),
      'TestIamPermissions': grpc.unary_unary_rpc_method_handler(
          servicer.TestIamPermissions,
          request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString,
          response_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'google.cloud.resourcemanager.v2.Folders', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
