Esempio n. 1
0
    def _MakeCreateRequest(self, args, messages, project, region,
                           commitment_ref, holder):

        if (args.split_source_commitment is not None
                and args.merge_source_commitments is not None):
            raise Exception(
                'It is not possible to merge and split in one request')

        commitment_type_flag = flags.GetTypeMapperFlag(messages)
        commitment_type = commitment_type_flag.GetEnumForChoice(args.type)
        commitment = messages.Commitment(
            reservations=reservation_helper.MakeReservations(
                args, messages, holder),
            name=commitment_ref.Name(),
            plan=flags.TranslatePlanArg(messages, args.plan),
            resources=flags.TranslateResourcesArgGroup(messages, args),
            type=commitment_type,
            autoRenew=flags.TranslateAutoRenewArg(args),
            splitSourceCommitment=args.split_source_commitment,
            mergeSourceCommitments=flags.TranslateMergeArg(
                args.merge_source_commitments))
        return messages.ComputeRegionCommitmentsInsertRequest(
            commitment=commitment,
            project=project,
            region=commitment_ref.region,
        )
Esempio n. 2
0
 def _MakeCreateRequest(self, args, messages, project, region,
                        commitment_ref, holder):
     commitment = messages.Commitment(
         name=commitment_ref.Name(),
         plan=flags.TranslatePlanArg(messages, args.plan),
         resources=flags.TranslateResourcesArgGroup(messages, args))
     return messages.ComputeRegionCommitmentsInsertRequest(
         commitment=commitment,
         project=project,
         region=commitment_ref.region,
     )
Esempio n. 3
0
 def _MakeCreateRequest(self, args, messages, project, region,
                        commitment_ref, holder):
     commitment_type_flag = flags.GetTypeMapperFlag(messages)
     commitment_type = commitment_type_flag.GetEnumForChoice(args.type)
     commitment = messages.Commitment(
         reservations=reservation_helper.MakeReservations(
             args, messages, holder),
         name=commitment_ref.Name(),
         plan=flags.TranslatePlanArg(messages, args.plan),
         resources=flags.TranslateResourcesArgGroup(messages, args),
         type=commitment_type)
     return messages.ComputeRegionCommitmentsInsertRequest(
         commitment=commitment,
         project=project,
         region=commitment_ref.region,
     )