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

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

Defined Under Namespace

Modules: Version

Instance Method Summary collapse

Instance Method Details

#delete_bundle_id_capability(bundle_id_capability_id:) ⇒ Object



133
134
135
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 133

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

#delete_certificate(certificate_id: nil) ⇒ Object



166
167
168
169
170
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 166

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

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

#delete_profile(profile_id: nil) ⇒ Object



271
272
273
274
275
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 271

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

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

#get_available_bundle_id_capabilities(bundle_id_id:) ⇒ Object



61
62
63
64
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 61

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

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



29
30
31
32
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 29

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("#{Version::V1}/bundleIds/#{bundle_id_id}", params)
end

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

bundleIdCapability



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

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("#{Version::V1}/bundleIds/#{bundle_id_id}/bundleIdCapabilities", params)
end

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

bundleIds



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

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("#{Version::V1}/bundleIds", params)
end

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



150
151
152
153
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 150

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("#{Version::V1}/certificates/#{certificate_id}", params)
end

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

certificates



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

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("#{Version::V1}/certificates", params)
  else
    provisioning_request_client.get("#{Version::V1}/profiles/#{profile_id}/certificates", params)
  end
end

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

devices



176
177
178
179
180
181
182
183
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 176

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("#{Version::V1}/devices", params)
  else
    provisioning_request_client.get("#{Version::V1}/profiles/#{profile_id}/devices", params)
  end
end

#get_profile_bundle_id(profile_id: nil) ⇒ Object



265
266
267
268
269
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 265

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

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

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

profiles



225
226
227
228
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 225

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("#{Version::V1}/profiles", params)
end

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



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
123
124
125
126
127
128
129
130
131
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 93

def patch_bundle_id_capability(bundle_id_id:, seed_id:, enabled: false, capability_type:, settings: [])
  body = {
    data: {
      type: "bundleIds",
      id: bundle_id_id,
      attributes: {
        permissions: {
          edit: true,
          delete: true
        },
        seedId: seed_id,
        teamId: provisioning_request_client.team_id
      },
      relationships: {
        bundleIdCapabilities: {
          data: [
            {
              type: "bundleIdCapabilities",
              attributes: {
                  enabled: enabled,
                  settings: settings
              },
              relationships: {
                capability: {
                  data: {
                      type: "capabilities",
                      id: capability_type
                    }
                }
              }
            }
          ]
        }
      }
    }
  }

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

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



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 202

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("#{Version::V1}/devices/#{id}", body)
end

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 34

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("#{Version::V1}/bundleIds", body)
end

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



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

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("#{Version::V1}/bundleIdCapabilities", body)
end

#post_certificate(attributes: {}) ⇒ Object



155
156
157
158
159
160
161
162
163
164
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 155

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

  provisioning_request_client.post("#{Version::V1}/certificates", body)
end

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



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 185

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("#{Version::V1}/devices", body)
end

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



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
255
256
257
258
259
260
261
262
263
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 230

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("#{Version::V1}/profiles", body)
end

#provisioning_request_clientObject

Raises:

  • (TypeError)


15
16
17
18
# File 'spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb', line 15

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



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

def provisioning_request_client=(provisioning_request_client)
  @provisioning_request_client = provisioning_request_client
end