def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: A serialized object (dict) describing the results of the operation. This description fits the Resource described in the ResourceRegistry under 'pubsub.projects.snapshots'. """ client = snapshots.SnapshotsClient() snapshot_ref = util.ParseSnapshot(args.snapshot) return client.Get(snapshot_ref)
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Yields: A serialized object (dict) describing the results of the operation. This description fits the Resource described in the ResourceRegistry under 'pubsub.projects.snapshots'. Raises: util.RequestFailedError: if any of the requests to the API failed. """ client = snapshots.SnapshotsClient() subscription_ref = util.ParseSubscription(args.subscription, args.subscription_project) labels = labels_util.ParseCreateArgs( args, client.messages.CreateSnapshotRequest.LabelsValue) failed = [] for snapshot_name in args.snapshot: snapshot_ref = util.ParseSnapshot(snapshot_name) try: result = client.Create(snapshot_ref, subscription_ref, labels=labels) except api_ex.HttpError as error: exc = exceptions.HttpException(error) log.CreatedResource(snapshot_ref.RelativeName(), kind='snapshot', failed=exc.payload.status_message) failed.append(snapshot_name) continue result = util.SnapshotDisplayDict(result) log.CreatedResource(snapshot_ref.RelativeName(), kind='snapshot') yield result if failed: raise util.RequestsFailedError(failed, 'create')
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Yields: Snapshot paths that match the regular expression in args.name_filter. Raises: sdk_ex.HttpException if there is an error with the regular expression syntax. """ client = snapshots.SnapshotsClient() for snapshot in client.List(util.ParseProject(), page_size=args.page_size): yield util.ListSnapshotDisplayDict(snapshot)
def SetUp(self): self.snapshots_client = snapshots.SnapshotsClient( self.client, self.msgs) self.snapshots_service = self.client.projects_snapshots