Drive API . parents

Instance Methods

delete(fileId=*, parentId=*, enforceSingleParent=None)

Removes a parent from a file.

get(fileId=*, parentId=*)

Gets a specific parent reference.

insert(fileId=*, body=None, enforceSingleParent=None, supportsTeamDrives=None, supportsAllDrives=None)

Adds a parent folder for a file.

list(fileId=*)

Lists a file's parents.

Method Details

delete(fileId=*, parentId=*, enforceSingleParent=None)
Removes a parent from a file.

Args:
  fileId: string, The ID of the file. (required)
  parentId: string, The ID of the parent. (required)
  enforceSingleParent: boolean, Set to true to opt in to API behavior that aims for all items to have exactly one parent. This parameter will only take effect if the item is not in a shared drive. If the item's last parent is removed, the item will be placed under its owner's root.
get(fileId=*, parentId=*)
Gets a specific parent reference.

Args:
  fileId: string, The ID of the file. (required)
  parentId: string, The ID of the parent. (required)

Returns:
  An object of the form:

    { # A reference to a file's parent.
    "selfLink": "A String", # A link back to this reference.
    "kind": "drive#parentReference", # This is always drive#parentReference.
    "id": "A String", # The ID of the parent.
    "isRoot": True or False, # Whether or not the parent is the root folder.
    "parentLink": "A String", # A link to the parent.
  }
insert(fileId=*, body=None, enforceSingleParent=None, supportsTeamDrives=None, supportsAllDrives=None)
Adds a parent folder for a file.

Args:
  fileId: string, The ID of the file. (required)
  body: object, The request body.
    The object takes the form of:

{ # A reference to a file's parent.
  "selfLink": "A String", # A link back to this reference.
  "kind": "drive#parentReference", # This is always drive#parentReference.
  "id": "A String", # The ID of the parent.
  "isRoot": True or False, # Whether or not the parent is the root folder.
  "parentLink": "A String", # A link to the parent.
}

  enforceSingleParent: boolean, Set to true to opt in to API behavior that aims for all items to have exactly one parent. This parameter will only take effect if the item is not in a shared drive. If the child's owner makes the request, the child will be removed from all current folders and placed in the requested folder. Any other requests that increase the number of the child's parents will fail, except when the canAddMyDriveParent file capability is true and a single parent is being added.
  supportsTeamDrives: boolean, Deprecated use supportsAllDrives instead.
  supportsAllDrives: boolean, Deprecated - Whether the requesting application supports both My Drives and shared drives. This parameter will only be effective until June 1, 2020. Afterwards all applications are assumed to support shared drives.

Returns:
  An object of the form:

    { # A reference to a file's parent.
    "selfLink": "A String", # A link back to this reference.
    "kind": "drive#parentReference", # This is always drive#parentReference.
    "id": "A String", # The ID of the parent.
    "isRoot": True or False, # Whether or not the parent is the root folder.
    "parentLink": "A String", # A link to the parent.
  }
list(fileId=*)
Lists a file's parents.

Args:
  fileId: string, The ID of the file. (required)

Returns:
  An object of the form:

    { # A list of a file's parents.
    "items": [ # The list of parents.
      { # A reference to a file's parent.
        "selfLink": "A String", # A link back to this reference.
        "kind": "drive#parentReference", # This is always drive#parentReference.
        "id": "A String", # The ID of the parent.
        "isRoot": True or False, # Whether or not the parent is the root folder.
        "parentLink": "A String", # A link to the parent.
      },
    ],
    "kind": "drive#parentList", # This is always drive#parentList.
    "etag": "A String", # The ETag of the list.
    "selfLink": "A String", # A link back to this list.
  }