Module: Google::Cloud::AIPlatform::V1::PredictionService::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/ai_platform/v1/prediction_service/paths.rb

Overview

Path helper methods for the PredictionService API.

Instance Method Summary collapse

Instance Method Details

#endpoint_path(project: , location: , endpoint: ) ⇒ ::String #endpoint_path(project: , location: , publisher: , model: ) ⇒ ::String

Create a fully-qualified Endpoint resource string.

Overloads:

  • #endpoint_path(project: , location: , endpoint: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/endpoints/{endpoint}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • endpoint (String) (defaults to: )
  • #endpoint_path(project: , location: , publisher: , model: ) ⇒ ::String

    The resource will be in the following format:

    projects/{project}/locations/{location}/publishers/{publisher}/models/{model}

    Parameters:

    • project (String) (defaults to: )
    • location (String) (defaults to: )
    • publisher (String) (defaults to: )
    • model (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/google/cloud/ai_platform/v1/prediction_service/paths.rb', line 50

def endpoint_path **args
  resources = {
    "endpoint:location:project" => (proc do |project:, location:, endpoint:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"

      "projects/#{project}/locations/#{location}/endpoints/#{endpoint}"
    end),
    "location:model:project:publisher" => (proc do |project:, location:, publisher:, model:|
      raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
      raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
      raise ::ArgumentError, "publisher cannot contain /" if publisher.to_s.include? "/"

      "projects/#{project}/locations/#{location}/publishers/#{publisher}/models/#{model}"
    end)
  }

  resource = resources[args.keys.sort.join(":")]
  raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
  resource.call(**args)
end