Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: third_party/gsutil/gslib/commands/setacl.py

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Removed gsutil/tests and gsutil/docs Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2011 Google Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from gslib.command import Command
16 from gslib.command import COMMAND_NAME
17 from gslib.command import COMMAND_NAME_ALIASES
18 from gslib.command import CONFIG_REQUIRED
19 from gslib.command import FILE_URIS_OK
20 from gslib.command import MAX_ARGS
21 from gslib.command import MIN_ARGS
22 from gslib.command import PROVIDER_URIS_OK
23 from gslib.command import SUPPORTED_SUB_ARGS
24 from gslib.command import URIS_START_ARG
25 from gslib.help_provider import HELP_NAME
26 from gslib.help_provider import HELP_NAME_ALIASES
27 from gslib.help_provider import HELP_ONE_LINE_SUMMARY
28 from gslib.help_provider import HELP_TEXT
29 from gslib.help_provider import HelpType
30 from gslib.help_provider import HELP_TYPE
31 from gslib.util import NO_MAX
32
33 _detailed_help_text = ("""
34 <B>SYNOPSIS</B>
35 gsutil setacl [-R] file-or-canned_acl_name uri...
36
37
38 <B>DESCRIPTION</B>
39 The setacl command allows you to set an Access Control List on one or
40 more buckets and objects. The simplest way to use it is to specify one of
41 the canned ACLs, e.g.,:
42
43 gsutil setacl private gs://bucket
44
45 or:
46
47 gsutil setacl public-read gs://bucket/object
48
49 See "gsutil help acls" for a list of all canned ACLs.
50
51 If you want to define more fine-grained control over your data, you can
52 retrieve an ACL using the getacl command (see "gsutil help getacl"),
53 save the output to a file, edit the file, and then use the gsutil setacl
54 command to set that ACL on the buckets and/or objects. For example:
55
56 gsutil getacl gs://bucket/file.txt > acl.txt
57 (Make changes to acl.txt such as adding an additional grant.)
58 gsutil setacl acl.txt gs://cats/file.txt
59
60 Note that you can set an ACL on multiple buckets or objects at once,
61 for example:
62
63 gsutil setacl acl.txt gs://bucket/*.jpg
64
65 If you have a large number of ACLs to update you might want to use the
66 gsutil -m option, to perform a parallel (multi-threaded/multi-processing)
67 update:
68
69 gsutil -m setacl acl.txt gs://bucket/*.jpg
70
71 Note that multi-threading/multi-processing is only done when the named URIs
72 refer to objects. gsutil -m setacl gs://bucket1 gs://bucket2 will run the
73 setacl operations sequentially.
74
75
76 <B>OPTIONS</B>
77 -R, -r Performs setacl request recursively, to all objects under the
78 specified URI.
79
80 -a Performs setacl request on all versions / generations.
81
82 -v Parses uris for version / generation numbers (only applicable in
83 version-enabled buckets). For example:
84
85 gsutil setacl -v public-read gs://bucket/object#1348772910166013
86
87 Note that wildcards are not permitted while using this flag.
88 """)
89
90
91 class SetAclCommand(Command):
92 """Implementation of gsutil setacl command."""
93
94 # Command specification (processed by parent class).
95 command_spec = {
96 # Name of command.
97 COMMAND_NAME : 'setacl',
98 # List of command name aliases.
99 COMMAND_NAME_ALIASES : [],
100 # Min number of args required by this command.
101 MIN_ARGS : 2,
102 # Max number of args required by this command, or NO_MAX.
103 MAX_ARGS : NO_MAX,
104 # Getopt-style string specifying acceptable sub args.
105 SUPPORTED_SUB_ARGS : 'aRrv',
106 # True if file URIs acceptable for this command.
107 FILE_URIS_OK : False,
108 # True if provider-only URIs acceptable for this command.
109 PROVIDER_URIS_OK : False,
110 # Index in args of first URI arg.
111 URIS_START_ARG : 1,
112 # True if must configure gsutil before running command.
113 CONFIG_REQUIRED : True,
114 }
115 help_spec = {
116 # Name of command or auxiliary help info for which this help applies.
117 HELP_NAME : 'setacl',
118 # List of help name aliases.
119 HELP_NAME_ALIASES : [],
120 # Type of help:
121 HELP_TYPE : HelpType.COMMAND_HELP,
122 # One line summary of this help.
123 HELP_ONE_LINE_SUMMARY : 'Set bucket and/or object ACLs',
124 # The full help text.
125 HELP_TEXT : _detailed_help_text,
126 }
127
128 # Command entry point.
129 def RunCommand(self):
130 if self.sub_opts:
131 for o, unused_a in self.sub_opts:
132 if o == '-a':
133 self.all_versions = True
134 elif o == '-r' or o == '-R':
135 self.recursion_requested = True
136 elif o == '-v':
137 self.parse_versions = True
138 self.SetAclCommandHelper()
139 return 0
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698