Module: Spaceship::ConnectAPI::Provisioning::API

Defined in:
spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb

Instance Method Summary collapse

Instance Method Details

#delete_bundle_id_capability(bundle_id_capability_id:) ⇒ Object



124
125
126
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 124

def delete_bundle_id_capability(bundle_id_capability_id:)
  provisioning_request_client.delete("bundleIdCapabilities/#{bundle_id_capability_id}")
end

#delete_certificate(certificate_id: nil) ⇒ Object



157
158
159
160
161
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 157

def delete_certificate(certificate_id: nil)
  raise "Certificate id is nil" if certificate_id.nil?

  provisioning_request_client.delete("certificates/#{certificate_id}")
end

#delete_profile(profile_id: nil) ⇒ Object



262
263
264
265
266
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 262

def delete_profile(profile_id: nil)
  raise "Profile id is nil" if profile_id.nil?

  provisioning_request_client.delete("profiles/#{profile_id}")
end

#get_available_bundle_id_capabilities(bundle_id_id:) ⇒ Object



57
58
59
60
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 57

def get_available_bundle_id_capabilities(bundle_id_id:)
  params = provisioning_request_client.build_params(filter: { bundleId: bundle_id_id })
  provisioning_request_client.get("capabilities", params)
end

#get_bundle_id(bundle_id_id: {}, includes: nil) ⇒ Object



25
26
27
28
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 25

def get_bundle_id(bundle_id_id: {}, includes: nil)
  params = provisioning_request_client.build_params(filter: nil, includes: includes, limit: nil, sort: nil)
  provisioning_request_client.get("bundleIds/#{bundle_id_id}", params)
end

#get_bundle_id_capabilities(bundle_id_id:, includes: nil, limit: nil, sort: nil) ⇒ Object

bundleIdCapability



52
53
54
55
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 52

def get_bundle_id_capabilities(bundle_id_id:, includes: nil, limit: nil, sort: nil)
  params = provisioning_request_client.build_params(filter: nil, includes: includes, limit: limit, sort: sort)
  provisioning_request_client.get("bundleIds/#{bundle_id_id}/bundleIdCapabilities", params)
end

#get_bundle_ids(filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) ⇒ Object

bundleIds



20
21
22
23
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 20

def get_bundle_ids(filter: {}, includes: nil, fields: nil, limit: nil, sort: nil)
  params = provisioning_request_client.build_params(filter: filter, includes: includes, fields: fields, limit: limit, sort: sort)
  provisioning_request_client.get("bundleIds", params)
end

#get_certificate(certificate_id: nil, includes: nil) ⇒ Object



141
142
143
144
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 141

def get_certificate(certificate_id: nil, includes: nil)
  params = provisioning_request_client.build_params(filter: nil, includes: includes, limit: nil, sort: nil)
  provisioning_request_client.get("certificates/#{certificate_id}", params)
end

#get_certificates(profile_id: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) ⇒ Object

certificates



132
133
134
135
136
137
138
139
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 132

def get_certificates(profile_id: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil)
  params = provisioning_request_client.build_params(filter: filter, includes: includes, fields: fields, limit: limit, sort: sort)
  if profile_id.nil?
    provisioning_request_client.get("certificates", params)
  else
    provisioning_request_client.get("profiles/#{profile_id}/certificates", params)
  end
end

#get_devices(profile_id: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) ⇒ Object

devices



167
168
169
170
171
172
173
174
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 167

def get_devices(profile_id: nil, filter: {}, includes: nil, fields: nil, limit: nil, sort: nil)
  params = provisioning_request_client.build_params(filter: filter, includes: includes, fields: fields, limit: limit, sort: sort)
  if profile_id.nil?
    provisioning_request_client.get("devices", params)
  else
    provisioning_request_client.get("profiles/#{profile_id}/devices", params)
  end
end

#get_profile_bundle_id(profile_id: nil) ⇒ Object



256
257
258
259
260
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 256

def get_profile_bundle_id(profile_id: nil)
  raise "Profile id is nil" if profile_id.nil?

  provisioning_request_client.get("profiles/#{profile_id}/bundleId")
end

#get_profiles(filter: {}, includes: nil, fields: nil, limit: nil, sort: nil) ⇒ Object

profiles



216
217
218
219
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 216

def get_profiles(filter: {}, includes: nil, fields: nil, limit: nil, sort: nil)
  params = provisioning_request_client.build_params(filter: filter, includes: includes, fields: fields, limit: limit, sort: sort)
  provisioning_request_client.get("profiles", params)
end

#patch_bundle_id_capability(bundle_id_id:, seed_id:, enabled: false, capability_type:, settings: []) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 89

def patch_bundle_id_capability(bundle_id_id:, seed_id:, enabled: false, capability_type:, settings: [])
  body = {
    data: {
      type: "bundleIds",
      id: bundle_id_id,
      attributes: {
        teamId: seed_id
      },
      relationships: {
        bundleIdCapabilities: {
          data: [
            {
              type: "bundleIdCapabilities",
              attributes: {
                  enabled: enabled,
                  settings: settings
              },
              relationships: {
                capability: {
                  data: {
                      type: "capabilities",
                      id: capability_type
                    }
                }
              }
            }
          ]
        }
      }
    }
  }

  provisioning_request_client.patch("bundleIds/#{bundle_id_id}", body)
end

#patch_device(id: nil, status: nil, new_name: nil) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 193

def patch_device(id: nil, status: nil, new_name: nil)
  raise "Device id is nil" if id.nil?

  attributes = {
    name: new_name,
    status: status
  }

  body = {
    data: {
      attributes: attributes,
      id: id,
      type: "devices"
    }
  }

  provisioning_request_client.patch("devices/#{id}", body)
end

#post_bundle_id(name:, platform:, identifier:, seed_id:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 30

def post_bundle_id(name:, platform:, identifier:, seed_id:)
  attributes = {
    name: name,
    platform: platform,
    identifier: identifier,
    seedId: seed_id
  }

  body = {
    data: {
      attributes: attributes,
      type: "bundleIds"
    }
  }

  provisioning_request_client.post("bundleIds", body)
end

#post_bundle_id_capability(bundle_id_id:, capability_type:, settings: []) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 62

def post_bundle_id_capability(bundle_id_id:, capability_type:, settings: [])
  body = {
    data: {
      attributes: {
        capabilityType: capability_type,
        settings: settings
      },
      type: "bundleIdCapabilities",
      relationships: {
        bundleId: {
          data: {
            type: "bundleIds",
            id: bundle_id_id
          }
        },
        capability: {
          data: {
            type: "capabilities",
            id: capability_type
          }
        }
      }
    }
  }
  provisioning_request_client.post("bundleIdCapabilities", body)
end

#post_certificate(attributes: {}) ⇒ Object



146
147
148
149
150
151
152
153
154
155
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 146

def post_certificate(attributes: {})
  body = {
    data: {
      attributes: attributes,
      type: "certificates"
    }
  }

  provisioning_request_client.post("certificates", body)
end

#post_device(name: nil, platform: nil, udid: nil) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 176

def post_device(name: nil, platform: nil, udid: nil)
  attributes = {
    name: name,
    platform: platform,
    udid: udid
  }

  body = {
    data: {
      attributes: attributes,
      type: "devices"
    }
  }

  provisioning_request_client.post("devices", body)
end

#post_profiles(bundle_id_id: nil, certificates: nil, devices: nil, attributes: {}) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 221

def post_profiles(bundle_id_id: nil, certificates: nil, devices: nil, attributes: {})
  body = {
    data: {
      attributes: attributes,
      type: "profiles",
      relationships: {
        bundleId: {
          data: {
            type: "bundleIds",
            id: bundle_id_id
          }
        },
        certificates: {
          data: certificates.map do |certificate|
            {
              type: "certificates",
              id: certificate
            }
          end
        },
        devices: {
          data: (devices || []).map do |device|
            {
              type: "devices",
              id: device
            }
          end
        }
      }
    }
  }

  provisioning_request_client.post("profiles", body)
end

#provisioning_request_clientObject

Raises:

  • (TypeError)


11
12
13
14
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 11

def provisioning_request_client
  return @provisioning_request_client if @provisioning_request_client
  raise TypeError, "You need to instantiate this module with provisioning_request_client"
end

#provisioning_request_client=(provisioning_request_client) ⇒ Object



7
8
9
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 7

def provisioning_request_client=(provisioning_request_client)
  @provisioning_request_client = provisioning_request_client
end