コード例 #1
0
    def Run(self, args):
        client = BmsClient()
        policy = args.CONCEPTS.snapshot_schedule_policy.Parse()
        description = args.description
        schedules = args.schedule
        labels_update = None
        labels_diff = labels_util.Diff.FromUpdateArgs(args)
        if labels_diff.MayHaveUpdates():
            orig_resource = client.GetSnapshotSchedulePolicy(policy)
            labels_update = labels_diff.Apply(
                client.messages.SnapshotSchedulePolicy.LabelsValue,
                orig_resource.labels).GetOrNone()

        if not description and not schedules and not labels_diff.MayHaveUpdates(
        ):
            raise exceptions.NoConfigurationChangeError(
                'No configuration change was requested. Did you mean to include the '
                'flags `--description` `--schedule` `--update-labels`'
                '`--remove-labels` or `--clear-labels`?')

        return client.UpdateSnapshotSchedulePolicy(policy_resource=policy,
                                                   labels=labels_update,
                                                   description=description,
                                                   schedules=schedules)
コード例 #2
0
 def Run(self, args):
     policy = args.CONCEPTS.snapshot_schedule_policy.Parse()
     client = BmsClient()
     return client.GetSnapshotSchedulePolicy(policy)