Esempio n. 1
0
def MatchClusters(ref, args, req):
    if args.match_clusters:
        req = utils.AddFieldToUpdateMask('cluster_selectors.labels', req)
        if req.scalingPolicy is None:
            req.scalingPolicy = utils.GetApiMessage(ref).ScalingPolicy()
        req.scalingPolicy.clusterSelectors = utils.ParseMatchClusters(
            ref, args.match_clusters)
    return req
Esempio n. 2
0
def MatchClusters(ref, args, req):
  if args.match_clusters or args.clear_match_clusters:
    req = utils.AddFieldToUpdateMask('cluster_selectors', req)
    if req.allocationPolicy is None:
      req.allocationPolicy = utils.GetApiMessage(ref).AllocationPolicy()
    req.allocationPolicy.clusterSelectors = []
  if args.match_clusters:
    req.allocationPolicy.clusterSelectors = utils.ParseMatchClusters(
        ref, args.match_clusters)
  return req
Esempio n. 3
0
def UpdateLabels(ref, args, req):
    """Update labels."""
    ref = GetResourceRef(args)
    labels_diff = labels_util.Diff.FromUpdateArgs(args)
    if labels_diff.MayHaveUpdates():
        req = utils.AddFieldToUpdateMask('labels', req)
        messages = GetMessagesForResource(ref)
        if req.scalingPolicy is None:
            req.scalingPolicy = utils.GetApiMessage(ref).ScalingPolicy()
        orig_resource = GetExistingResource(ref)
        new_labels = labels_diff.Apply(messages.LabelsValue,
                                       orig_resource.labels).GetOrNone()
        if new_labels:
            req.scalingPolicy.labels = new_labels
        else:
            req.scalingPolicy.labels = orig_resource.labels
    return req
Esempio n. 4
0
def GetRequestMessage(resource_ref):
    return utils.GetApiMessage(
        resource_ref).GameservicesProjectsLocationsScalingPoliciesGetRequest(
            name=resource_ref.RelativeName())