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

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

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « third_party/gsutil/gslib/commands/rm.py ('k') | third_party/gsutil/gslib/commands/setcors.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 updates:
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
81
82 class SetAclCommand(Command):
83 """Implementation of gsutil setacl command."""
84
85 # Command specification (processed by parent class).
86 command_spec = {
87 # Name of command.
88 COMMAND_NAME : 'setacl',
89 # List of command name aliases.
90 COMMAND_NAME_ALIASES : [],
91 # Min number of args required by this command.
92 MIN_ARGS : 2,
93 # Max number of args required by this command, or NO_MAX.
94 MAX_ARGS : NO_MAX,
95 # Getopt-style string specifying acceptable sub args.
96 SUPPORTED_SUB_ARGS : 'Rr',
97 # True if file URIs acceptable for this command.
98 FILE_URIS_OK : False,
99 # True if provider-only URIs acceptable for this command.
100 PROVIDER_URIS_OK : False,
101 # Index in args of first URI arg.
102 URIS_START_ARG : 1,
103 # True if must configure gsutil before running command.
104 CONFIG_REQUIRED : True,
105 }
106 help_spec = {
107 # Name of command or auxiliary help info for which this help applies.
108 HELP_NAME : 'setacl',
109 # List of help name aliases.
110 HELP_NAME_ALIASES : [],
111 # Type of help:
112 HELP_TYPE : HelpType.COMMAND_HELP,
113 # One line summary of this help.
114 HELP_ONE_LINE_SUMMARY : 'Set ACLs on buckets and/or objects',
115 # The full help text.
116 HELP_TEXT : _detailed_help_text,
117 }
118
119 # Command entry point.
120 def RunCommand(self):
121 if self.sub_opts:
122 for o, unused_a in self.sub_opts:
123 if o == '-r' or o == '-R':
124 self.recursion_requested = True
125 self.SetAclCommandHelper()
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/commands/rm.py ('k') | third_party/gsutil/gslib/commands/setcors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698